[openstack-dev] [Horizon] Edit subnet in workflows - ip_version hidden?

Radomir Dopieralski openstack at sheep.art.pl
Tue Mar 11 15:30:06 UTC 2014

On 11/03/14 15:52, Abishek Subramanian (absubram) wrote:
> Hi,
> I had a question regarding the
> dashboards/project/networks/subnets/workflows.py
> file and in particular the portion of the ip_version field.
> It is marked as a hidden input field for the update subnet class with this
> note.
> # NOTE(amotoki): When 'disabled' attribute is set for the ChoiceField
>     # and ValidationError is raised for POST request, the initial value of
>     # the ip_version ChoiceField is not set in the re-displayed form
>     # As a result, 'IPv4' is displayed even when IPv6 is used if
>     # ValidationError is detected. In addition 'required=True' check
> complains
>     # when re-POST since the value of the ChoiceField is not set.
>     # Thus now I use HiddenInput for the ip_version ChoiceField as a work
>     # around.
> Can I get a little more context to this please?
> I'm not sure I understand why it says this field always is displayed as
> IPv4.
> Is this still the case? Adding some debug logs I seem to see that the
> ipversion is correctly being detected as 4 or 6 as the case may be.

Some browsers (Chrome, iirc) will not submit the values from form fields
that are disabled. That means, that when re-displaying this form
(after an error in any other field, for example), that field's value
will be missing, and the browser will happily display the first option,
which is ipv4.

Another solution could be perhaps using "readonly" instead of "disabled".

Radomir Dopieralski

More information about the OpenStack-dev mailing list