Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default widget for colander.Date differs from what the documentation states #165

Closed
ghost opened this issue May 30, 2013 · 8 comments
Closed

Comments

@ghost
Copy link

ghost commented May 30, 2013

I have a simple text input generated for a colander.Date field instead of the default deform.widget.DateInputWidget indicated in the documentation : http://docs.pylonsproject.org/projects/deform/en/latest/common_needs.html#changing-the-default-widget-associated-with-a-field

@ghost
Copy link
Author

ghost commented May 30, 2013

I have already read this part of the documentation. The HTML markup is really rendered with type="text" and if in my python code, I add an explicit widget=DateInputWidget() then it is fine (I have the jQuery ui date picker) and the input in rendered with type="date".

@mcdonc
Copy link
Member

mcdonc commented May 30, 2013

Can you tell me if the widget at http://deformdemo.repoze.org/dateinput/ renders incorrectly for you? If so, what browser/version are you using?

@ghost
Copy link
Author

ghost commented May 30, 2013

Fortunately, the HTML rendering does not seem to depend on the browser. I tested under:

  • Chromium Version 27.0.1453.93 (200836)
  • Firefox Version 21.0
  • Safari Version 5.1.9 (6534.59.8)

and they all give the same result, which is the following:

  <!-- mapping_item -->

  <label
         class="desc"
         title=""
         for="deformField1"
         >Date<span class="req"
                        id="req-deformField1">*</span>
  </label>


    <input type="date"
           name="date"
           value="2010-05-05"
           id="deformField1"/>
    <script type="text/javascript">
      deform.addCallback(
        'deformField1',
        function(oid) {
              if (!Modernizr.inputtypes['date'] ||
                   "date" != "date"){
                $('#' + oid).datepicker({'dateFormat': 'yy-mm-dd'});
              }
        }
      );
    </script>

Here, I can see the type="date" in the input which looks fine indeed.

@mcdonc
Copy link
Member

mcdonc commented May 30, 2013

Yes, the HTML will be the same, I meant "does it look/work ok".

@ghost
Copy link
Author

ghost commented May 30, 2013

Under Chromium, I see the date picker from the browser itself.
Under Firefox, I see the date picker from jQuery ui.
Under Safari, I see the date picker from jQuery ui.

They all look fine. However, concerning my specific problem, it occurs before starting to look at what is rendered by the browsers. Indeed, this is what is received by the browser (an input with type="text") that I don't understand.

@mcdonc
Copy link
Member

mcdonc commented May 30, 2013

It sounds like the DateTime widget is behaving as designed. I'm pretty sure I don't understand the actual problem. Can you describe it as if I am a five year old?

@ghost
Copy link
Author

ghost commented May 30, 2013

In simple words, when I build a schema node like this:

    schema.add(colander.SchemaNode(
        MySpecificDate(),
        description=_('form.marketingseason-update.salesperiod-begin-date-description',
            default="Enter the begin date of the sales period with the format dd/mm/yyyy."),
        name='begindate',
        title=_('form.marketingseason-update.salesperiod-begin-date-label', default="Begin date"),
        widget=TextInputWidget()
    ))

it produces the same as I build the schema node like this:

    schema.add(colander.SchemaNode(
        MySpecificDate(),
        description=_('form.marketingseason-update.salesperiod-begin-date-description',
            default="Enter the begin date of the sales period with the format dd/mm/yyyy."),
        name='begindate',
        title=_('form.marketingseason-update.salesperiod-begin-date-label', default="Begin date")
    ))

Ok, writing that, I realize my mistake, I am not using colander.Date but my version of it MySpecificDate which explains why I don't have the deform.widget.DateInputWidget as default widget.

Sorry

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant