List Info

Thread: Weight values function?




Weight values function?
country flaguser name
Brazil
2007-12-24 07:58:19
There is in drupal core a function to return the #options to my weight fields? (-10 to 10, i.e.)
 
I'm searching in the includes folder, without success 
 

Thanks
 
Feijó
 
Re: Weight values function?
country flaguser name
United States
2007-12-24 09:43:37
Weights are used in several places, and always as an
integer, I don't
think that there is anything that restricts it from -10 to
10.

Drupal core does it by using the 'type' => '#weight'. 
See

http://api.drupal.org/?q=api
/file/developer/topics/forms_api_reference.html/5#weight


Also look at process_weight in includes/form.inc.

I'm not really sure why it's done this way.  I would of
simply used: 
'#type' => 'select', '#options' =>
drupal_map_assoc(range(-10, 10))

Alessandro Feijó wrote:
> There is in drupal core a function to return the
#options to my weight fields? (-10 to 10, i.e.)
>
> I'm searching in the includes folder, without success

>
>
> Thanks
>
> Feijó
>
>   


Re: Weight values function?
country flaguser name
Brazil
2007-12-24 10:26:36
What I'm looking for is the type you mentioned!!

'#type' => 'weight',


This solved the issue... Thanks Doug

The drupal_map_assoc was the function I thought I saw, very
usefull... noted 
for future use.

I know I can use any value, not only integer.  Float is
valid as well, you 
can have an menu with weight 4.1, and other with 4.11


Feijó


----- Original Message ----- 
From: "Doug Green" <douggreendouggreenconsulting.com>
To: <developmentdrupal.org>
Sent: Monday, December 24, 2007 1:43 PM
Subject: Re: [development] Weight values function?


> Weights are used in several places, and always as an
integer, I don't
> think that there is anything that restricts it from -10
to 10.
>
> Drupal core does it by using the 'type' =>
'#weight'.  See
>
> http://api.drupal.org/?q=api
/file/developer/topics/forms_api_reference.html/5#weight

>
> Also look at process_weight in includes/form.inc.
>
> I'm not really sure why it's done this way.  I would of
simply used:
> '#type' => 'select', '#options' =>
drupal_map_assoc(range(-10, 10))
>
> Alessandro Feijó wrote:
>> There is in drupal core a function to return the
#options to my weight 
>> fields? (-10 to 10, i.e.)
>>
>> I'm searching in the includes folder, without
success 
>>
>>
>> Thanks
>>
>> Feijó
>>


Re: Weight values function?
country flaguser name
United States
2007-12-26 11:43:51
On Dec 24, 2007, at 8:26 AM, Alessandro Feijó wrote:

> I know I can use any value, not only integer.  Float is
valid as  
> well, you can have an menu with weight 4.1, and other
with 4.11

Only if the weight is being stored in the DB in a float,
which is  
never the case in the core schema.

cheers,
-derek (dww)



[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )