[support] D7 Trouble altering comment form

Jeff Greenberg listmail.ayendesigns at gmail.com
Fri Nov 1 23:15:23 UTC 2013


Ah, right! Thanks. So for the buttons, I really wanted to do:

        $form['actions']['submit'] = t('Post comment');
        unset($form['actions']['preview']);

But what also is revealed is that the title *Add new comment* is not part
of the form. I'd appreciate any idea regarding overriding its value. I
tried using content: xxx in css, but while I can get the new value to
appear doing that, I can't seem to hide the original one without hiding
both.


On Fri, Nov 1, 2013 at 3:30 PM, berliner <myberliner at gmail.com> wrote:

> What you did was to alter the node object that was passed into the form
> builder as an argument.
> Instead var_dump the entire $form array and look for keys that do not
> start with a dash. Those are the ones that will finally be rendered. Keys
> starting with a dash control how they are rendered.
> Take a look at the examples in the docs:
> https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_form_alter/7
>
> best regards,
> berliner
>
> Am 01.11.2013 um 19:34 schrieb Jeff Greenberg <
> listmail.ayendesigns at gmail.com>:
>
> > I have the following code in my module:
> >
> >     function mymodule_form_alter(&$form, &$form_state, $form_id) {
> >       if ($form_id == 'comment_node_blog_form') {
> >
> $form['#node']->content['links']['comment']['#links']['comment-add']['title']
> = t('Post a comment');
> >         $form['#node']->actions['submit'] = t('Post comment');
> >         unset($form['#node']->actions['preview']);
> >     var_dump($form);
> >   }
> >
> > When I look at the var_dump, the form fields are set as intended.
> However, in looking at the form, the title still has "Add new comment", the
> submit button is unchanged, and the preview button is still present.
> >
> > In searching the page content (including the var_dump output) the ONLY
> place 'Add' exists is in the text of the form ... NOT in the content of the
> var_dump. The only way I can see that happening is if the form array is
> being changed back after my hook, so I tried changing the module weight to
> 99 (via mysql) and clearing cache. No difference.
> >
> >
> > --
> > ---
> > drupal.org/user/367108
> > linkedin.com/in/jeffrgreenberg
> > accidentalcoder.com / ayendesigns.com
> > @accidentalcoder
> > --
> > [ Drupal support list | http://lists.drupal.org/ ]
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>



-- 
---
drupal.org/user/367108
linkedin.com/in/jeffrgreenberg
accidentalcoder.com / ayendesigns.com
@accidentalcoder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20131101/493263d8/attachment.html 


More information about the support mailing list