Changeset 294

Show
Ignore:
Timestamp:
09/03/07 15:01:44 (1 year ago)
Author:
matt
Message:

Add immutable support to the SelectOtherChoice? widget. (Sorry for ignoring your
email for all this time Paul Reznicek!)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/formal/html/SelectOtherChoice.html

    r158 r294  
    11<n:invisible xmlns:n="http://nevow.com/ns/nevow/0.1"> 
    2   <span class="select-with-other"> 
     2 
     3  <span n:pattern="editable" class="select-with-other"> 
    34    <n:attr name="id"><n:slot name="id"/></n:attr> 
    45    <select> 
     
    1415    <input type="text"><n:attr name="name"><n:slot name="key" />-other</n:attr><n:attr name="value"><n:slot name="otherValue"/></n:attr></input> 
    1516  </span> 
     17 
     18  <span n:pattern="immutable" class="select-with-other"> 
     19    <n:attr name="id"><n:slot name="id"/></n:attr> 
     20    <select disabled="disabled"> 
     21      <n:attr name="name"><n:slot name="key"/></n:attr> 
     22      <n:slot name="options"> 
     23      <option n:pattern="option"><n:attr name="value"><n:slot name="value"/></n:attr><n:slot name="label">One</n:slot></option> 
     24      <option selected="selected" n:pattern="selectedOption"><n:attr name="value"><n:slot name="value"/></n:attr><n:slot name="label">One</n:slot></option> 
     25      <option>Two</option> 
     26      <option>Three</option> 
     27      <option value="...">Other ...</option> 
     28      </n:slot> 
     29    </select> 
     30    <input readonly="readonly" type="text"><n:attr name="name"><n:slot name="key" />-other</n:attr><n:attr name="value"><n:slot name="otherValue"/></n:attr></input> 
     31  </span> 
     32 
    1633</n:invisible> 
  • trunk/formal/widget.py

    r286 r294  
    371371 
    372372    def render(self, ctx, key, args, errors): 
     373        return self._render(ctx, key, args, errors, False) 
     374 
     375    def renderImmutable(self, ctx, key, args, errors): 
     376        return self._render(ctx, key, args, errors, True) 
     377 
     378    def _render(self, ctx, key, args, errors, immutable): 
    373379 
    374380        charset = util.getPOSTCharset(ctx) 
     
    383389            value = iformal.IKey(self.noneOption).key() 
    384390 
    385         optionGen = inevow.IQ(self.template).patternGenerator('option') 
    386         selectedOptionGen = inevow.IQ(self.template).patternGenerator('selectedOption') 
     391        if immutable: 
     392            template = inevow.IQ(self.template).onePattern('immutable') 
     393        else: 
     394            template = inevow.IQ(self.template).onePattern('editable') 
     395        optionGen = template.patternGenerator('option') 
     396        selectedOptionGen = template.patternGenerator('selectedOption') 
    387397        optionTags = [] 
    388398        selectOther = True 
     
    420430        optionTags.append(tag) 
    421431 
    422         tag = T.invisible[self.template.load(ctx)] 
     432        tag = template 
    423433        tag.fillSlots('key', key) 
    424434        tag.fillSlots('id', render_cssid(key)) 
     
    426436        tag.fillSlots('otherValue', otherValue) 
    427437        return tag 
    428  
    429     def renderImmutable(self, ctx, key, args, errors): 
    430         raise NotImplemented 
    431438 
    432439    def processInput(self, ctx, key, args): 
  • trunk/setup.py

    r293 r294  
    33setup( 
    44    name='formal', 
    5     version='0.15.3', 
     5    version='0.15.4', 
    66    description='HTML forms framework for Nevow', 
    77    author='Matt Goodall',