On Thu, Dec 11, 2008 at 9:11 AM, Erik Andersson <[EMAIL PROTECTED]> wrote:

> On Wed, Dec 10, 2008 at 1:08 PM, Alexandre Rocha <[EMAIL PROTECTED]>wrote:
>
>>  Jani Tiainen escreveu:
>>
>> Erik Andersson kirjoitti:
>>
>>
>>  Hi
>>
>> I asked around on #trac but noone seemed to be able to help me out, so
>> maybe I'm doing it wrong.. I'll ask here as well just to be sure.
>>
>> I'm playing with some ticket templates. I wanted to be able to set the
>> ticket type depending on the template used and then disable the type
>> dropdown so that the type cannot be changed..
>> I'm using a streamfilter to disable the dropdown:
>> Transformer("//[EMAIL PROTECTED]'field-type']").attr('disabled', 'disabled')
>>
>> It looks good when viewing and entering data into the ticket, but when
>> saved/submitted the ticket type is still the default type.
>> I also tried setting type=workorder in the URL as some people
>> recommended, but still no effect. When submitting, the type value is the
>> default.
>>
>> I'm guessing the problem to be related to that I'm disabling the
>> type-dropdown
>>
>>
>>  User agents usually don't send disabled fields.
>>
>> So you need to create hidden field with correct name and value and then
>> setup phantom display value to your dropdown - propably with piece of JS
>> if enabled to copy selected value to hidden field.
>>
>>
>>
>>  Its a good idea
>> Did you try to use readonly instead disabled ?
>>
>
> Hmm. I cannot find any READONLY attribute for SELECT. Seems there is som
> way to do that with an javascript, is that what you mean?
>
> Currently I have it working, quite ugly and I'm thinking there must be a
> better way to do this..
>
> return Transformer("//[EMAIL PROTECTED]'field-type']").attr('disabled',
> 'disabled').attr('id','field_type_org').attr('name','field_type_org').after(HTML('''<select
> id="field-type" name="field_type" style="display:none;"><option
> selected="selected">workorder</option><option>bug</option> </select>'''))
>
> I will at least try to do a copy of the original select-tag and add
> style="display:none;" to that and then add that to after instead of the
> currently hard coded tag
>
> Is there something more minimal I can add instead of the whole select-tag?
>
> Cheers / Erik
>

Ok. With help from osimons and cmlenz, this is what I have now:
Transformer("//[EMAIL PROTECTED]'field-type']").attr('disabled',
'disabled').attr('id','field_type_org').a\
ttr('name','field_type_org').after(HTML('''<input id='field-type'
name='field_type' type="hidden" value="workorder" />'''))

The dropdown is visible, but disabled. The real value is stored in a hidden
field.

The hard coded value needs to be set depending on the ticket type, but that
should be easy.


>
>
>>
>>
>>
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/trac-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to