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

Abishek Subramanian (absubram) absubram at cisco.com
Tue Mar 11 15:57:04 UTC 2014


Thanks Radomir.

Yes I've changed it to a readonly. But just wanted to double check
I didn't end up breaking something elsewhere :)

Althouh - how up to date is this code?

These are the actual lines of code -

# 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.
    ip_version = forms.ChoiceField(choices=[(4, 'IPv4'), (6, 'IPv6')],
                                   #widget=forms.Select(
                                   #    attrs={'disabled': 'disabled'}),
                                   widget=forms.HiddenInput(),
                                   label=_("IP Version"))




I don't think ip_version even has an attribute or an option to be set to
'disabled'.
Is this from an old version where the create side got fixed but the update
side was forgotten about?


On 3/11/14 11:30 AM, "Radomir Dopieralski" <openstack at sheep.art.pl> wrote:

>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
>
>
>_______________________________________________
>OpenStack-dev mailing list
>OpenStack-dev at lists.openstack.org
>http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev




More information about the OpenStack-dev mailing list