[Catalyst] FormBuilder: HOWTO make a particular OPTION disabled in a SELECT form?

will at serensoft.com will at serensoft.com
Sat Jun 12 23:05:19 GMT 2010


Catalyst (and Chaining in particular) is really, really sweet! Enjoying the
exploration immensely. So here's our next puzzle:

Objective: to DISABLE some of the <OPTION>s in a <SELECT> field.

        $teams =3D [
            map { [ $_->id, $_->name ] } @teams
        ];
        $form->field(
            name    =3D> "user.$id.team",
            options =3D> $teams,
            value   =3D> $user->team->id,
            selectname =3D> 'Select Team:',
            required   =3D> 1,
        );

This gives us something like the following:

<select id=3D"my_team" name=3D"my_team">
  <option value=3D"">Select Team</option>
  <option value=3D"1">Alpha</option>
  <option value=3D"9">Bravo</option>
  <option value=3D"2">Delta (inactive)</option>
  <option value=3D"7">Echo</option>
  <option value=3D"6">Foxtrot</option>
</select>

We'd like to disable the SELECTNAME option and any INACTIVE options:

<select id=3D"my_team" name=3D"my_team">
  <option value=3D"" DISABLED>Select Team</option>
  <option value=3D"1">Alpha</option>
  <option value=3D"9">Bravo</option>
  <option value=3D"2" DISABLED>Delta (inactive)</option>
  <option value=3D"7">Echo</option>
  <option value=3D"6">Foxtrot</option>
</select>

We've tried using UNDEF in place of the team->id:

        $teams->[2][0] =3D undef; # where $teams->[2][1] eq 'Delta (inactiv=
e)'

But that just gives

  <option>Delta (inactive)</option>

Is there a way to include DISABLED options without s/// after
$form->prepare?

-- =

will trillich
"I think it would be worse to expect nothing than to be disappointed." --
Anne (with an 'e') Shirley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100612/f005f=
e27/attachment.htm


More information about the Catalyst mailing list