drupal - Add range to each option in a dropdown menu array instead of single value? -
edit:
my original post included @ bottom of issue, vague, i'm trying update make myself more clear. there section of site users submit reviews of businesses. in 1 such field, select whether or not had bar tab. given options of none, drinks, food, , both. when submit option stored in database float value, none being stored 0, drinks 1, food 2, , both 3. avg of these values single field display on pages of businesses. so, if business has average value of .5 bar tab shows "none", value of 1.2 "drinks", etc.
i have view displays teasers of business pages, , users can filter results results of fields on business page. have dropdown menu display options filter, i'm not sure how assign range each value in array instead of single value. here's have:
$options = array( '' => 'any', '0' => 'none', '1' => 'drinks', '2' => 'food', '3' => 'both', );
as can see, if user selects "drinks" option in filter, pages value of 1 in float field show up. however, far user concerned, selection of "drinks" should filter pages "drinks" value, or float value of >.75 && <=1.5
. need options in array reflect that. so, although following code not correct, i'd want effect of:
$options = array( '' => 'any', '>=0 && <=0.75' => 'none', '>0.75 && <=1.5' => 'drinks', '>1.5 && <=2.25' => 'food', '>2.25 && <=3' => 'both', );
does know how go doing this? hope clearer original post.
original:
i asked on in drupal forum while ago, haven't been able responses, i'm hoping here can me out. have following code in module select array.
$options = array( '' => 'any', '0' => 'none', '1' => 'drinks', '2' => 'food', '3' => 'both', );
however, problem each option related single value. there way instead assign range each option? result value between 0 , 1 assigned none, value between 1 , 2 assigned drinks, etc.?
based on our conversation above, , if it's true array keys encoded value="" of form fields, , therefore passed subsequent page, suggestion this:
move implementation handling request instead of form-generating one. i'm not familiar drupal development (not in last 2 years anyway), imagine have hooks on subsequent request can modify submitted values before picked framework select query.
something keep eye on: won't able use strings on other side, since drupal escapes values, puts them in quotes, , uses = comparison operator. may need check drupal docs how specify expression when selecting.
Comments
Post a Comment