Results 1 to 13 of 13

Thread: Disable field

  1. #1
    User
    Join Date
    06-19-09.
    Location
    Elbl?g, Poland
    Posts
    152

    Default Disable field

    in my DCA I have field:
    Code:
    		'sumaNum' => array
    		(
    			'label'                   => &$GLOBALS['TL_LANG']['tl_antique_books']['sumaNum'],
    			'default'                 => 0,
    			'inputType'               => 'text',
    			'eval'                    => array('rgxp'=>'digit', 'disable'=>true, 'tl_class'=>'w50 sumnum')
    		),
    as you see in eval there is a 'disable'=>true but it's not working. I read at the reference page (http://www.typolight.org/reference.html) that: "Disables the field (not supported by all field types)" so in this case I assume disable doesn't support the text field. Am I right or do something wrong?
    Marcin

    http://www.contao.pl - Polish Support Site
    http://forum.contao.pl - Polish Contao community forum


    -----------------------
    Need custom template? Feel free to contact me by e-mail marcin@contao.pl

  2. #2
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Disable field

    Qrczak, I'm not sure what disabling a field means.
    You just want it to be readonly?
    Code:
    'readonly'=>'readonly'
    Otherwise try
    Code:
    'disabled'=>'disabled'
    or
    Code:
    'disable'=>'disabled'
    (I'm guessing!)

    Or if you don't want it to show at all in the backend form just remove its name from your palette array.

  3. #3
    Core developer
    Official Contao Team
    leo's Avatar
    Join Date
    06-04-09.
    Location
    Wuppertal, Germany
    Posts
    201

    Default Re: Disable field

    Text fields should be supported. Which TYPOlight version are you using?

  4. #4
    User
    Join Date
    06-19-09.
    Location
    Elbl?g, Poland
    Posts
    152

    Default Re: Disable field

    Hi ramjet and Leo,

    Quote Originally Posted by ramjet
    Code:
    'disabled'=>'disabled'
    Thanks ramjet - this one works.

    Leo, but it's strange becouse on reference page (http://www.typolight.org/reference.html) there is clearly that:

    Code:
    disable - true/false
                boolean
    and that's why I try to use "'disable'=>true". But it's seems like it's a mistake.

    Quote Originally Posted by ramjet
    Or if you don't want it to show at all in the backend form just remove its name from your palette array.
    I know but I need this field inside my module becouse js script will collect and counting numbers values from other fields to this one automaticly. That's why I don't want let user provide his own value and that's why this field should be disabled.
    Marcin

    http://www.contao.pl - Polish Support Site
    http://forum.contao.pl - Polish Contao community forum


    -----------------------
    Need custom template? Feel free to contact me by e-mail marcin@contao.pl

  5. #5
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Disable field

    Thanks ramjet - this one works.'disabled'=>'disabled'
    Good guess ay... :D

    Is that different to making the field readonly?

  6. #6
    User
    Join Date
    06-19-09.
    Location
    Elbl?g, Poland
    Posts
    152

    Default Re: Disable field

    Quote Originally Posted by ramjet
    Is that different to making the field readonly?
    Actually it's no diffrent only that if you have readonly field and hover it you get edit cursor, only this I think.
    Marcin

    http://www.contao.pl - Polish Support Site
    http://forum.contao.pl - Polish Contao community forum


    -----------------------
    Need custom template? Feel free to contact me by e-mail marcin@contao.pl

  7. #7
    Core developer
    Official Contao Team
    leo's Avatar
    Join Date
    06-04-09.
    Location
    Wuppertal, Germany
    Posts
    201

    Default Re: Disable field

    Quote Originally Posted by qrczak
    Leo, but it's strange becouse on reference page (http://www.typolight.org/reference.html) there is clearly that:
    Based on the Widget.php code, it should work with 'disabled'=>true.

  8. #8
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Disable field

    There you go, the reference says
    disable
    , but Leo is saying
    disabled
    .

  9. #9
    Core developer
    Official Contao Team
    leo's Avatar
    Join Date
    06-04-09.
    Location
    Wuppertal, Germany
    Posts
    201

    Default Re: Disable field

    The devil is in the details I have corrected the developer's guide.

  10. #10
    User
    Join Date
    06-19-09.
    Location
    Elbl?g, Poland
    Posts
    152

    Default Re: Disable field

    Yeah, that was it, thanks! :D
    Marcin

    http://www.contao.pl - Polish Support Site
    http://forum.contao.pl - Polish Contao community forum


    -----------------------
    Need custom template? Feel free to contact me by e-mail marcin@contao.pl

  11. #11
    User
    Join Date
    01-25-10.
    Location
    France
    Posts
    61

    Default Re: Disable field

    Hello,

    I am searching some means to manage a readonly and mandatory field, a select menu item, in a form

    This field is set to mandatory in the form manager of the backend
    It is initialised with a default value in this form (I change the item type to a text field for setting this default value and I come back to the select menu field afterthat)

    In a loadFormField hook about this form the field is set :
    - to a special value with a __set('value',valeur) on the target widget
    - to readonly on the same widget

    in fact,the above treatment is switched upon member categories (some can modify the field , the other no)

    All is good : the field is displayed with the good value and it is in readonly mode.

    But:
    after the form is validated , TL tells me : "No, No the field is mandatory" ..!
    bit it has a value by default .... and an other one with the loadFormField hook...

    I found nothing inside TL code except that :
    this error message is set because nothing is entered (by hands I guess) in the related input (field) object

    Some one can help ?
    Thanks
    Sharing and growing

  12. #12
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Disable field

    You cannot set a field to be mandatory AND readonly.... without a value posted... you'll have to UNSET the widget's mandatory in the loadfield or simply remove it from the form settings. if you want to, you can set additional varialbles/settings/checks in the validate form field (I should know, since I requested these hooks, load/validate, LOL)

  13. #13
    User
    Join Date
    01-25-10.
    Location
    France
    Posts
    61

    Default Re: Disable field

    Thyon , Thanks a lot for replying

    It is a pity that readonly fields cant' be read back in the validate Hook ....

    Ok it 's always possible to prevent writting by javascript, but in this case, it's not so simple to set a readonly state according to specfic considerations (member's category for instance or member's rights)

    Perhaps could it be possible to simulate an input in the readonly field by posting a variable in this field ?
    Sharing and growing

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •