[html-formfu] providing condition attributes for Select box
while using DBIC
mohanprasad
mohan at thebizmo.com
Fri Apr 3 12:27:39 BST 2009
2009/4/3 mohanprasad <mohan at thebizmo.com>:
>
> hello everybody,
>
> i am trying to provide a select box in a html form.
> All the options should come database using DBIC.
> I want to filter the database entries fetched using DBIC.
> >From the documentation http://search.cpan.org/~cfranks/HTML-FormFu-Model-DBIC-0.03007/lib/HTML/FormFu/Model/DBIC.pm i got to know i can make use of condition attribute to filter the results fetched using DBIC.
> Documentation is telling condition will work similar to 1st arguement in search method on a result set.
> my code is as follows:
>
> ---
> action:
> auto_fieldset: 1
> auto_id: '%f_%n'
> elements:
> - type: Select
> name: media_type
> label: 'select media type:* '
> model_config:
> model: Database::mediatype
> label_column: name
> id_column: name
> condition:
> name: 'video'
> constraints:
> - Required
>
> The above one will get all entries from mediatype table where name = 'video'.
> could anybody let me know if i want to provide not condition (ex: name != 'video') or a simple where clause like(ex: (field1 = 'value1' OR filed2 != 'value2') how should i do that?
Hi,
This is core DBIx::Class stuff.
You should find examples for both of these in the docs for SQL::Abstract
Cheers,
Carl
_______________________________________________
HTML-FormFu mailing list
HTML-FormFu at lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
Hi Carl,
Thank you so much for the response.
I have gone through SQL::Abstract documentation.
Figured it out how to do the stuff.
I have updated the code as follows and IT WORKS
- type: Select
name: media_type
label: 'select media type:* '
model_config:
model: Database::mediatype
label_column: name
id_column: name
condition:
name:
'!=': 'video'
constraints:
- Required
Best Regards,
Mohan
--
View this message in context: http://n2.nabble.com/providing-condition-attributes-for-Select-box-while-using-DBIC-tp2580015p2580138.html
Sent from the HTML-FormFu mailing list archive at Nabble.com.
More information about the HTML-FormFu
mailing list