Results 1 to 6 of 6

Thread: DCA Attempting to submit mandatory fields

  1. #1
    User
    Join Date
    08-07-09.
    Location
    Kent, United Kingdom
    Posts
    92

    Default DCA Attempting to submit mandatory fields

    Within a DCA I am writing, A drop-down field defines the membership class for a member.
    However for some membership classes some fields are to be removed from the default DCA, before it refreshes the page it runs checks on DCA fields that are being removed.

    As they are marked as mandatory the form can't refresh due to the error.

  2. #2
    User
    Join Date
    08-07-09.
    Location
    Kent, United Kingdom
    Posts
    92

    Default Re: DCA Attempting to submit mandatory fields

    I've found out the behavior to duplicate this bug, I'll provide a working implementation of the BUG for Contao devs to try ASAP.

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

    Default Re: DCA Attempting to submit mandatory fields

    Why not just create a selector to switch the palette. The the unwanted fields can then be removed, eg standard member with 1 palette of fields and then extended with an additional fields in the palette. You can also setup the correct palette in an onload_callback (reading it from the parent or dome other condition).

  4. #4
    User
    Join Date
    08-07-09.
    Location
    Kent, United Kingdom
    Posts
    92

    Default Re: DCA Attempting to submit mandatory fields

    The bug has been reported here :http://dev.contao.org/issues/2684 with a demo module of the problem.

  5. #5
    User
    Join Date
    08-07-09.
    Location
    Kent, United Kingdom
    Posts
    92

    Default Re: DCA Attempting to submit mandatory fields

    The following code is a small hack to alter this behavior, however the bug still stands:
    Code:
    class tl_bug_palette extends Backend{
        function field_save($value,$dca){
            $this->import('Database');
            $r=$this->Database->prepare('SELECT palette from tl_bug_palette WHERE id=?')
                ->execute($dca->id);
            if($r->palette!=$value){
                $GLOBALS['TL_DCA']['tl_bug_palette']['fields']['alpha']['eval']['mandatory']=false;
            }
            return $value;
        }
    }
    This should be added to the save_callback for the palette selector field that is being used:
    Code:
    		'palette' => array
    		(
    			'label'                   => &$GLOBALS['TL_LANG']['tl_bug_palette']['palette'],
    			'default'                 => 'palette1',
    			'exclude'                 => true,
    			'sorting'                 => true,
    			'flag'                    => 11,
    			'filter'                  => true,
    			'inputType'               => 'select',
    			'options'		  => array('palette1','palette2','palette3'),
    			'save_callback'		  => array(
    				array('tl_bug_palette','field_save')
    			),
    			'eval'                    => array('submitOnChange'=>true, 'tl_class'=>'w100')
    		)

  6. #6
    User
    Join Date
    08-07-09.
    Location
    Kent, United Kingdom
    Posts
    92

    Default Re: DCA Attempting to submit mandatory fields

    Eeek!
    My fix introduces a further bug that an empty record can then exist since the select menu change is saving the record.

    Until a fix has been decided on for the actual issue, I'll look into coding a cleanup function.

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
  •