Hi Jagdish -

        my @options = $c->model('myleavedb::txn_mdl')->search({emp_no =>
$c->user->emp_no},{columns => [qw/lv_id/]});

When you do the search via the model, @options will be an array of objects of the type defined in "myleavedb::txn_mdl". Because of your "columns" specification, each of those objects will have the "lv_id" column/method available.


        foreach my $option(@options) {
        push (@new_options,$option->lv_id)
        }
        $c->stash->{myoptions} = [EMAIL PROTECTED];

I don't understand in what way @options and @new_options are different
from each other, but in a bumbling manner I have made the code work.

Your new code loops over the objects, pulls out lv_id values into @new_options, and passes [EMAIL PROTECTED] into the template.

Another way would be to pass [EMAIL PROTECTED] directly into the template, and in your template you would use something like:

   FOREACH options IN options;
       lv_id = options.lv_id;
       ... do stuff with lv_id ...
   END

Depending on circumstances this may be a better approach in the long run because, for example, later you may decide you need additional columns from @options, and you would be able to access those in your template as option.lv_id, option.some_other_method, etc.


Larry

_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to