set_element_properties for thor form view

3 views
Skip to first unread message

Steve

unread,
Oct 22, 2009, 2:58:16 PM10/22/09
to Reason Discussion
$grad_year = $this->get_element_name_from_label('High School
Graduation Year');
$this->change_element_type($grad_year, 'year');
$this->set_element_properties($grad_year, array
('num_years_after_today' => 4, 'num_years_before_today' => 4,));

Hi all,

I'm wondering if anyone can tell me why the set_element_properties
method isn't working in the above code. I've done successfully done
this before in other form views on the textdatetime type.

Much appreciated,
Steve

Matt Ryan

unread,
Oct 23, 2009, 1:18:18 AM10/23/09
to reason-d...@googlegroups.com
The code looks OK to me -- nothing obvious that would keep things from
working. The first thing I would check would be to make sure that my
IP was getting notices, though, because
$this->get_element_name_from_label('High School Graduation Year'); is
inherently fragile -- any change to the label and the method will
return false.

Not really a solution so much as an FYI: you should be able to do the
same thing in two lines:

$grad_year = $this->get_element_name_from_label('High School Graduation Year');
$this->change_element_type($grad_year, 'year',
array('num_years_after_today' => 4, 'num_years_before_today' => 4,));

-- Matt

Steve

unread,
Oct 23, 2009, 9:31:04 AM10/23/09
to Reason Discussion
Thanks Matt. When I used the condensed code you provided it worked
like a charm. I wonder why set_element_properties failed.

Steve

On Oct 23, 12:18 am, Matt Ryan <matt.d.r...@gmail.com> wrote:
> The code looks OK to me -- nothing obvious that would keep things from
> working. The first thing I would check would be to make sure that my
> IP was getting notices, though, because
> $this->get_element_name_from_label('High School Graduation Year'); is
> inherently fragile -- any change to the label and the method will
> return false.
>
> Not really a solution so much as an FYI: you should be able to do the
> same thing in two lines:
>
> $grad_year = $this->get_element_name_from_label('High School Graduation Year');
> $this->change_element_type($grad_year, 'year',
> array('num_years_after_today' => 4, 'num_years_before_today' => 4,));
>
> -- Matt
>

Matt Ryan

unread,
Oct 24, 2009, 2:10:29 PM10/24/09
to reason-d...@googlegroups.com
I agree, it's odd, and might represent a bug. If you can identify in
what cases it seems to be failing -- is it just that plasmature type,
or is it some other condition in the form? -- we'd love it if you
could describe the issue in the issue tracker on the Google Code site.

Matt

Steve

unread,
Oct 26, 2009, 11:26:44 AM10/26/09
to Reason Discussion
OK. I'll do some more testing to try and narrow down the cases. Then
I'll submit it via the issue tracker.


Thanks for the help,
Steve
Reply all
Reply to author
Forward
0 new messages