[support] Form Doubt

Austin Einter austin.einter at gmail.com
Tue Mar 15 11:17:52 UTC 2011


This issue is resolved.

Regards
Austin.


Hi
I found that value is retreived properly, but when I increment it by 1 it
does not work.

My code in hook_form_alter is as below.

 if($form_id == myformid)
 {
    $form_state['values']['companies'] = $form_state['values']['companies']
+ 1;
 }

Is this the way values can be incremented, or I need to follow any
particular




On Tue, Mar 15, 2011 at 7:10 AM, Austin Einter <austin.einter at gmail.com>wrote:

> Hi All
> As per form quickstart guide, forms can have #type as 'values'.
>
> Example:
>
> <?php
> $form['foo'] = array('#type' => 'value', '#value' => 'bar')
> ?>
>
> Later point of time, we can retreive the value as
> $form_state['values']['foo'], and value retreived should be 'bar'.
>
> In my module hook_form api, I have added
>
>  $form['companies'] = array(
>  '#type' => 'value',
>  '#value' => '1',
>  );
> In hook_form_alter, I want to get the value of
> $form_state['values']['companies'] and increment
> $form_state['values']['companies'] by 1.
> Is this allowed or Drupal has any restriction.
>
> When I access the value of $form_state['values']['companies'], it just
> gives me empty value ('').
>
> What could be problem here?
>
> Regards
> Austin
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20110315/ddc4edcf/attachment.html 


More information about the support mailing list