Git Product home page Git Product logo

contao-haste's People

Contributors

ameotoko avatar aschempp avatar baumannsven avatar bytehead avatar dmolineus avatar doishub avatar fiedsch avatar fritzmg avatar icodr8 avatar leofeyer avatar m-vo avatar markocupic avatar munsio avatar qzminski avatar rabauss avatar richardhj avatar salteax avatar tastaturberuf avatar toflar avatar wusch avatar zonky2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

contao-haste's Issues

getAttributesFromDca() fix

Hey guys,

There was an issue in the previous version of hasteform with getAttributesFromDca (previously prepareForWidget).
Do you remember?

I remember it was somehow a problem of DCA representations. One was FE-like and the other BE-like, wasn't it? And hasteform sort of mixed them up which also prevented my initial version of the loadFieldsFromFormGenerator() to work so we had to drop it again :(.

I can't quite remember what exactly the problem was but I know I haven't resolved this in 2.0 yet ;-) Can you remember by chance @aschempp @qzminski ?

Multiple forms with captcha

Hi,

If you add multiple forms to a page and each of them contains a captcha field, only the last field is saved to session data (it overrides the actual value).

I fixed this by adding the formId value to the name of the captcha field :

    public function addCaptcha($arrData=array())
    {
        if (!isset($this->arrFields['captcha']))
        {
            $this->arrFields['captcha'] = array_merge_recursive(array
            (
                'name'      => 'captcha_'.$this->strFormId,
                'label'     => $GLOBALS['TL_LANG']['MSC']['securityQuestion'],
                'inputType' => 'captcha',
                'eval'      => array('mandatory'=>true)
            ), $arrData);
        }
    }

Thanks,
Fabien

Tableless layout: Yes

It's me again.

The Code generated looks like this and is invalid:

`

Pflichtfeld Titel*
`

Should be as follows:

`


Pflichtfeld Titel*

`

Problem when a template is changed

Hi,

I have a problem when I change a template. To explain this, my module display a search form and a link for creating a new job :

First function :

        // Search form
        $arrFields = array
        (
            'contract_type' => array
            (
                ...
            ),
            'categories' => array
            (
                ...
            )
        );

        // First param is the form id
        $objForm = new HasteForm('search_jobs', $arrFields);

        // The submit button
        $objForm->submit = $GLOBALS['TL_LANG']['MSC']['form_search'];

        // Get the form as string
        $objForm->addFormToTemplate($this->Template);

        // Validate() also checks whether the form has been submitted
        if ($objForm->validate())
        {
            // Fetch all form data
            $arrData = $objForm->fetchAll();
        }

       ...

If I use this link I change the template with a new form.

Second function :

$arrFields = array
        (
            'title' => array
            (
                ...
            ),
            'description' => array
            (
               ...
            )
            ...
        );

        // Change the template
        $this->Template = new FrontendTemplate('jb_jobForm');

        // Add "tr" and "td" tags on each field of the form
        foreach ($arrFields as $key => $value) {
            $arrFields[$key]['eval']['tableless'] = FALSE;
        }

        // First param is the form id
        $objForm = new HasteForm('job_offer', $arrFields);

        // The submit button
        $objForm->submit = $GLOBALS['TL_LANG']['MSC']['form_submit'];

        // Get the form as string
        $objForm->addFormToTemplate($this->Template);

        // Validate() also checks whether the form has been submitted
        if ($objForm->validate())
        {
            // Fetch all form data
            $arrData = $objForm->fetchAll();

            ...

The template is changed. That's OK. But not the form. The first form is inserted into the second form.

Normally I should have "title", "description", ... but I have "contract_type", "categories", ... and the id of the form is not changed.

Do you have an idea of the problem ?

Thx

Problem with no DCA fields without inputType

If I have a Contao3 DCA with fields whithout any inputType and haste throws an error.

Fatal error: Uncaught exception RuntimeException with message The class "" for type "" could not be found. thrown in system/modules/haste/library/Haste/Form/Form.php on line 250 

#0 system/modules/haste/library/Haste/Form/Form.php(376): Haste\Form\Form->addFormField('id', Array)

The DCA configuration looks like this.

// Fields
    'fields' => array
    (
        'id' => array
        (
            'sql' => "int(10) unsigned NOT NULL auto_increment"
        ),
        'tstamp' => array
        (
            'sql' => "int(10) unsigned NOT NULL default '0'"
        ),
        'member' => array
        (
            'label'                   => &$GLOBALS['TL_LANG']['tl_o3go_core']['member'],
            'exclude'                 => true,
            'filter'                  => true,
            'sorting'                 => true,
            'flag'                    => 11,
            'inputType'               => 'select',
            'foreignKey'              => 'tl_member.username',
            'eval'                    => array('doNotCopy'=>true, 'chosen'=>true, 'mandatory'=>true, 'tl_class'=>'w50 clr'),
            'sql'                     => "int(10) unsigned NOT NULL default '0'",
            'relation'                => array('type'=>'belongsTo', 'load'=>'eager')
        ),

I think there must be a check for fields whithout inputType in the addFieldsFromDca function which can look like this:

 foreach ($arrFields as $k => $v) {

            if(!isset($v['inputType'])) {
                continue;
            }

            if (is_callable($varCallback) && !call_user_func_array($varCallback, array(&$k, &$v))) {
                continue;
            }

            $this->addFormField($k, $v);
        }

Isotope [2.0.rc1] - Checkout Error

in checkout process this error comes

Fatal error: Call to undefined method Haste\Units\Mass\Scale::getUnits() in ../system/modules/haste/library/Haste/Units/Mass/Weight.php on line 56 

Problem with deleting files in the "File manager"

When opening the "File manager" and deleting a file the following error message shows up.

Recoverable error: Argument 1 passed to Haste\Model\Relations::cleanRelatedRecords() must be an instance of Contao\DataContainer, string given, called in /home/xxx/public_html/system/modules/core/drivers/DC_Folder.php on line 750 and defined in system/modules/haste/library/Haste/Model/Relations.php on line 138
#0 system/modules/haste/library/Haste/Model/Relations.php(138): __error(4096, 'Argument 1 pass...', '/home/xxx/...', 138, Array)
#1 system/modules/core/drivers/DC_Folder.php(750): Haste\Model\Relations->cleanRelatedRecords('files/isotope/i...', Object(Contao\DC_Folder))
#2 system/modules/core/classes/Backend.php(424): Contao\DC_Folder->delete()
#3 contao/main.php(136): Contao\Backend->getBackendModule('files')
#4 contao/main.php(287): Main->run()
#5 {main}

Do not delete GET parameters

Currently, when setting an action the potential GET parameters are deleted (if method is "get"). In my opinion, this is wrong. It would be much better to automatically generate hidden fields for all parameters.

Fehler bei gleichzeitiger Verwendung von EFG

Wenn man im Contao Backend unter "Feedback" einen Eintrag löschen will, erhält man die Fehlermeldung:

Fatal error: Cannot redeclare class tl_fd_feedback in ......./system/modules/efg/dca/fd_feedback.php on line 731

Das ganze passiert nicht, wenn "haste" nicht aktiviert ist.

Automatically generated relation table name is not correct

This causes relations not working properly in all cases.

$arrTables = array($strTableOne, $strTableTwo);
natcasesort($arrTables);
return $arrTables[0] . '_' . str_replace('tl_', '', $arrTables[1]);

natcasesort sorts the array correctly but preserves keys so the function in fact does nothing :-(
We need to do this:

$arrTables = array($strTableOne, $strTableTwo);
natcasesort($arrTables);
$arrTables = array_values($arrTables);
return $arrTables[0] . '_' . str_replace('tl_', '', $arrTables[1]);

This will cause existing table names to be changed which Haste has to take care of in an update script. If you use the API of haste (= all the helper methods) nothing will break. If, however, you wrote your own SQL query referencing a dynamically generated relation table, your code will break.
Example:

  • Relation between tables tl_content and tl_page defined in tl_page.
  • Haste generated tl_page_content automatically for you instead of tl_content_page.
  • Thus your SQL query SELECT * FROM tl_page_content; will now fail.

We decided not to release a version 5 and not to declare this as a BC break because if you use the API of haste (= all the helper methods like the shipped Model class and using getRelated() on it) nothing will break.
Using a dynamically generated table in your own query is NOT API and you should have never done that. There are two solutions you should have used (and use in the future) which would have prevented you from running into that issue:

1: Use the API:

// 1st variant
$relation = Relations::getRelation('tl_page', 'field_name');
$query = sprintf('SELECT * FROM %s', $relation['table']);

// 2nd variant
$query = sprintf('SELECT * FROM %s', Relations::getTableName('tl_content', 'tl_page'));

2: Define the relation table manually:

// DCA
$GLOBALS['TL_DCA']['tl_page']['fields']['my_field']['relation'] = array
(
    'type' => 'haste-ManyToMany',
    'load' => 'lazy',
    'table' => 'tl_content'
    'relationTable' => 'tl_my_superb_relation_table'
);

// Code
$query = 'SELECT * FROM tl_my_superb_relation_table';

Unit testing

Let's introduce some unit testing, if possible.

inputs type hidden

Hi,

There are no values for the inputs type hidden...

hidden

             ...
             'published' => array
                (
                'name' => 'published',
                'value' => 1,
                'inputType' => 'hidden',
                'eval' => array('rgxp' => 'num')
            ),
            'author' => array
                (
                'name' => 'author',
                'value' => $this->User->id,
                'inputType' => 'hidden',
                'eval' => array('rgxp' => 'num')
            ),
            'tstamp' => array
                (
                'name' => 'tstamp',
                'value' => time(),
                'inputType' => 'hidden',
                'eval' => array()
            ),
            ...

We need to specify something for Haste ?

Error without DCA

Warning: Invalid argument supplied for foreach() in system/modules/haste/library/Haste/Model/Relations.php on line 38
#0 system/modules/haste/library/Haste/Model/Relations.php(38): __error(2, 'Invalid argumen...', '/home/httpd/vho...', 38, Array)
#1 system/modules/core/library/Contao/Controller.php(2378): Haste\Model\Relations->addRelationCallbacks('tl_countryresp')
#2 system/modules/core/drivers/DC_Table.php(3150): Contao\Controller->loadDataContainer('tl_countryresp')
#3 system/modules/core/drivers/DC_Table.php(333): Contao\DC_Table->reviseTable()
#4 system/modules/core/classes/Backend.php(424): Contao\DC_Table->showAll()
#5 contao/main.php(136): Contao\Backend->getBackendModule('page')
#6 contao/main.php(287): Main->run()
#7 {main}

There is no DCA for the table tl_countryresp

class for widget / fields

would be great to have fieldname as class in line 606:
$strBuffer .= '

' . $objWidget->parse() . '
';

also for submit button.
regards klaus

Fieldset + Legend

Hi,

I would like to add a fieldset and a legend.

<fieldset><legend><b><?php echo $this->fieldset_legend; ?></b></legend>

...

</fieldset>

There is this function but... $objForm->addFieldSet('year');

Is there a solution with Haste ?

Error on Contao 3.2 and MetaModels/Composer

My setting:

  • Contao 3.2
  • Composer Client
  • MetaModels (Current version)
  • Isotope 2.0.0 Releasebranch
  • DC_General

The error is displayed in the install tool.

Warning: Invalid argument supplied for foreach() in system/modules/haste/library/Haste/Model/Relations.php on line 38

#0 system/modules/haste/library/Haste/Model/Relations.php(38): __error(2, 'Invalid argumen...', '/var/www/kunden...', 38, Array)
#1 system/modules/core/library/Contao/Controller.php(2378): Haste\Model\Relations->addRelationCallbacks('tl_syncCto_clie...')
#2 system/modules/core/library/Contao/DcaExtractor.php(291): Contao\Controller->loadDataContainer('tl_syncCto_clie...')
#3 system/modules/core/library/Contao/DcaExtractor.php(114): Contao\DcaExtractor->createExtract()
#4 system/modules/core/library/Contao/Database/Installer.php(294): Contao\DcaExtractor->__construct('tl_syncCto_clie...')
#5 system/modules/core/library/Contao/Database/Installer.php(117): Contao\Database\Installer->getFromDca()
#6 system/modules/core/library/Contao/Database/Installer.php(47): Contao\Database\Installer->compileCommands()
#7 contao/install.php(630): Contao\Database\Installer->generateSqlForm()
#8 contao/install.php(197): InstallTool->adjustDatabaseTables()
#9 contao/install.php(1093): InstallTool->run()
#10 {main}


Warning: Invalid argument supplied for foreach() in system/modules/haste/library/Haste/Model/Relations.php on line 274

#0 system/modules/haste/library/Haste/Model/Relations.php(274): __error(2, 'Invalid argumen...', '/var/www/kunden...', 274, Array)
#1 system/modules/core/library/Contao/Database/Installer.php(409): Haste\Model\Relations->addRelationTables(Array)
#2 system/modules/core/library/Contao/DcaExtractor.php(326): Contao\Database\Installer->getFromFile()
#3 system/modules/core/library/Contao/DcaExtractor.php(114): Contao\DcaExtractor->createExtract()
#4 system/modules/core/library/Contao/Database/Installer.php(294): Contao\DcaExtractor->__construct('tl_syncCto_clie...')
#5 system/modules/core/library/Contao/Database/Installer.php(117): Contao\Database\Installer->getFromDca()
#6 system/modules/core/library/Contao/Database/Installer.php(47): Contao\Database\Installer->compileCommands()
#7 contao/install.php(630): Contao\Database\Installer->generateSqlForm()
#8 contao/install.php(197): InstallTool->adjustDatabaseTables()
#9 contao/install.php(1093): InstallTool->run()
#10 {main}


Warning: Invalid argument supplied for foreach() in system/modules/haste/library/Haste/Model/Relations.php on line 274

#0 system/modules/haste/library/Haste/Model/Relations.php(274): __error(2, 'Invalid argumen...', '/var/www/kunden...', 274, Array)
#1 system/modules/core/library/Contao/Database/Installer.php(409): Haste\Model\Relations->addRelationTables(Array)
#2 system/modules/core/library/Contao/DcaExtractor.php(326): Contao\Database\Installer->getFromFile()
#3 system/modules/core/library/Contao/DcaExtractor.php(114): Contao\DcaExtractor->createExtract()
#4 system/modules/core/library/Contao/Database/Installer.php(294): Contao\DcaExtractor->__construct('tl_syncCto_clie...')
#5 system/modules/core/library/Contao/Database/Installer.php(117): Contao\Database\Installer->getFromDca()
#6 system/modules/core/library/Contao/Database/Installer.php(47): Contao\Database\Installer->compileCommands()
#7 contao/install.php(630): Contao\Database\Installer->generateSqlForm()
#8 contao/install.php(197): InstallTool->adjustDatabaseTables()
#9 contao/install.php(1093): InstallTool->run()
#10 {main}


Warning: Invalid argument supplied for foreach() in system/modules/haste/library/Haste/Model/Relations.php on line 274

#0 system/modules/haste/library/Haste/Model/Relations.php(274): __error(2, 'Invalid argumen...', '/var/www/kunden...', 274, Array)
#1 system/modules/core/library/Contao/Database/Installer.php(409): Haste\Model\Relations->addRelationTables(Array)
#2 system/modules/core/library/Contao/DcaExtractor.php(326): Contao\Database\Installer->getFromFile()
#3 system/modules/core/library/Contao/DcaExtractor.php(114): Contao\DcaExtractor->createExtract()
#4 system/modules/core/library/Contao/Database/Installer.php(294): Contao\DcaExtractor->__construct('tl_syncCto_rest...')
#5 system/modules/core/library/Contao/Database/Installer.php(117): Contao\Database\Installer->getFromDca()
#6 system/modules/core/library/Contao/Database/Installer.php(47): Contao\Database\Installer->compileCommands()
#7 contao/install.php(630): Contao\Database\Installer->generateSqlForm()
#8 contao/install.php(197): InstallTool->adjustDatabaseTables()
#9 contao/install.php(1093): InstallTool->run()
#10 {main}


Warning: Invalid argument supplied for foreach() in system/modules/haste/library/Haste/Model/Relations.php on line 274

#0 system/modules/haste/library/Haste/Model/Relations.php(274): __error(2, 'Invalid argumen...', '/var/www/kunden...', 274, Array)
#1 system/modules/core/library/Contao/Database/Installer.php(409): Haste\Model\Relations->addRelationTables(Array)
#2 system/modules/core/library/Contao/DcaExtractor.php(326): Contao\Database\Installer->getFromFile()
#3 system/modules/core/library/Contao/DcaExtractor.php(114): Contao\DcaExtractor->createExtract()
#4 system/modules/core/library/Contao/Database/Installer.php(294): Contao\DcaExtractor->__construct('tl_syncCto_rest...')
#5 system/modules/core/library/Contao/Database/Installer.php(117): Contao\Database\Installer->getFromDca()
#6 system/modules/core/library/Contao/Database/Installer.php(47): Contao\Database\Installer->compileCommands()
#7 contao/install.php(630): Contao\Database\Installer->generateSqlForm()
#8 contao/install.php(197): InstallTool->adjustDatabaseTables()
#9 contao/install.php(1093): InstallTool->run()
#10 {main}


Warning: Invalid argument supplied for foreach() in system/modules/haste/library/Haste/Model/Relations.php on line 274

#0 system/modules/haste/library/Haste/Model/Relations.php(274): __error(2, 'Invalid argumen...', '/var/www/kunden...', 274, Array)
#1 system/modules/core/library/Contao/Database/Installer.php(409): Haste\Model\Relations->addRelationTables(Array)
#2 system/modules/core/library/Contao/DcaExtractor.php(326): Contao\Database\Installer->getFromFile()
#3 system/modules/core/library/Contao/DcaExtractor.php(114): Contao\DcaExtractor->createExtract()
#4 system/modules/core/library/Contao/Database/Installer.php(294): Contao\DcaExtractor->__construct('tl_syncCto_sett...')
#5 system/modules/core/library/Contao/Database/Installer.php(117): Contao\Database\Installer->getFromDca()
#6 system/modules/core/library/Contao/Database/Installer.php(47): Contao\Database\Installer->compileCommands()
#7 contao/install.php(630): Contao\Database\Installer->generateSqlForm()
#8 contao/install.php(197): InstallTool->adjustDatabaseTables()
#9 contao/install.php(1093): InstallTool->run()
#10 {main}


Warning: Invalid argument supplied for foreach() in system/modules/haste/library/Haste/Model/Relations.php on line 274

#0 system/modules/haste/library/Haste/Model/Relations.php(274): __error(2, 'Invalid argumen...', '/var/www/kunden...', 274, Array)
#1 system/modules/core/library/Contao/Database/Installer.php(409): Haste\Model\Relations->addRelationTables(Array)
#2 system/modules/core/library/Contao/DcaExtractor.php(326): Contao\Database\Installer->getFromFile()
#3 system/modules/core/library/Contao/DcaExtractor.php(114): Contao\DcaExtractor->createExtract()
#4 system/modules/core/library/Contao/Database/Installer.php(294): Contao\DcaExtractor->__construct('tl_theme_plus_j...')
#5 system/modules/core/library/Contao/Database/Installer.php(117): Contao\Database\Installer->getFromDca()
#6 system/modules/core/library/Contao/Database/Installer.php(47): Contao\Database\Installer->compileCommands()
#7 contao/install.php(630): Contao\Database\Installer->generateSqlForm()
#8 contao/install.php(197): InstallTool->adjustDatabaseTables()
#9 contao/install.php(1093): InstallTool->run()
#10 {main}


Warning: Invalid argument supplied for foreach() in system/modules/haste/library/Haste/Model/Relations.php on line 274

#0 system/modules/haste/library/Haste/Model/Relations.php(274): __error(2, 'Invalid argumen...', '/var/www/kunden...', 274, Array)
#1 system/modules/core/library/Contao/Database/Installer.php(409): Haste\Model\Relations->addRelationTables(Array)
#2 system/modules/core/library/Contao/DcaExtractor.php(326): Contao\Database\Installer->getFromFile()
#3 system/modules/core/library/Contao/DcaExtractor.php(114): Contao\DcaExtractor->createExtract()
#4 system/modules/core/library/Contao/Database/Installer.php(294): Contao\DcaExtractor->__construct('tl_theme_plus_s...')
#5 system/modules/core/library/Contao/Database/Installer.php(117): Contao\Database\Installer->getFromDca()
#6 system/modules/core/library/Contao/Database/Installer.php(47): Contao\Database\Installer->compileCommands()
#7 contao/install.php(630): Contao\Database\Installer->generateSqlForm()
#8 contao/install.php(197): InstallTool->adjustDatabaseTables()
#9 contao/install.php(1093): InstallTool->run()
#10 {main}


Warning: Invalid argument supplied for foreach() in system/modules/haste/library/Haste/Model/Relations.php on line 274

#0 system/modules/haste/library/Haste/Model/Relations.php(274): __error(2, 'Invalid argumen...', '/var/www/kunden...', 274, Array)
#1 system/modules/core/library/Contao/Database/Installer.php(409): Haste\Model\Relations->addRelationTables(Array)
#2 system/modules/core/library/Contao/DcaExtractor.php(326): Contao\Database\Installer->getFromFile()
#3 system/modules/core/library/Contao/DcaExtractor.php(114): Contao\DcaExtractor->createExtract()
#4 system/modules/core/library/Contao/Database/Installer.php(294): Contao\DcaExtractor->__construct('tl_iso_product')
#5 system/modules/core/library/Contao/Database/Installer.php(117): Contao\Database\Installer->getFromDca()
#6 system/modules/core/library/Contao/Database/Installer.php(47): Contao\Database\Installer->compileCommands()
#7 contao/install.php(630): Contao\Database\Installer->generateSqlForm()
#8 contao/install.php(197): InstallTool->adjustDatabaseTables()
#9 contao/install.php(1093): InstallTool->run()
#10 {main}


Warning: Invalid argument supplied for foreach() in system/modules/haste/library/Haste/Model/Relations.php on line 274

#0 system/modules/haste/library/Haste/Model/Relations.php(274): __error(2, 'Invalid argumen...', '/var/www/kunden...', 274, Array)
#1 system/modules/core/library/Contao/Database/Installer.php(409): Haste\Model\Relations->addRelationTables(Array)
#2 system/modules/core/library/Contao/DcaExtractor.php(326): Contao\Database\Installer->getFromFile()
#3 system/modules/core/library/Contao/DcaExtractor.php(114): Contao\DcaExtractor->createExtract()
#4 system/modules/core/library/Contao/Database/Installer.php(294): Contao\DcaExtractor->__construct('tl_iso_product_...')
#5 system/modules/core/library/Contao/Database/Installer.php(117): Contao\Database\Installer->getFromDca()
#6 system/modules/core/library/Contao/Database/Installer.php(47): Contao\Database\Installer->compileCommands()
#7 contao/install.php(630): Contao\Database\Installer->generateSqlForm()
#8 contao/install.php(197): InstallTool->adjustDatabaseTables()
#9 contao/install.php(1093): InstallTool->run()
#10 {main}


Warning: Invalid argument supplied for foreach() in system/modules/haste/library/Haste/Model/Relations.php on line 274

#0 system/modules/haste/library/Haste/Model/Relations.php(274): __error(2, 'Invalid argumen...', '/var/www/kunden...', 274, Array)
#1 system/modules/core/library/Contao/Database/Installer.php(409): Haste\Model\Relations->addRelationTables(Array)
#2 system/modules/core/library/Contao/DcaExtractor.php(326): Contao\Database\Installer->getFromFile()
#3 system/modules/core/library/Contao/DcaExtractor.php(114): Contao\DcaExtractor->createExtract()
#4 system/modules/core/library/Contao/Database/Installer.php(294): Contao\DcaExtractor->__construct('tl_iso_rule')
#5 system/modules/core/library/Contao/Database/Installer.php(117): Contao\Database\Installer->getFromDca()
#6 system/modules/core/library/Contao/Database/Installer.php(47): Contao\Database\Installer->compileCommands()
#7 contao/install.php(630): Contao\Database\Installer->generateSqlForm()
#8 contao/install.php(197): InstallTool->adjustDatabaseTables()
#9 contao/install.php(1093): InstallTool->run()
#10 {main}


Warning: Invalid argument supplied for foreach() in system/modules/haste/library/Haste/Model/Relations.php on line 274

#0 system/modules/haste/library/Haste/Model/Relations.php(274): __error(2, 'Invalid argumen...', '/var/www/kunden...', 274, Array)
#1 system/modules/core/library/Contao/Database/Installer.php(409): Haste\Model\Relations->addRelationTables(Array)
#2 system/modules/core/library/Contao/Database/Installer.php(118): Contao\Database\Installer->getFromFile()
#3 system/modules/core/library/Contao/Database/Installer.php(47): Contao\Database\Installer->compileCommands()
#4 contao/install.php(630): Contao\Database\Installer->generateSqlForm()
#5 contao/install.php(197): InstallTool->adjustDatabaseTables()
#6 contao/install.php(1093): InstallTool->run()
#7 {main}


Warning: Cannot modify header information - headers already sent by (output started at /var/www/kundenprojekte/pizzasteinversand/system/helper/functions.php:70) in system/modules/core/library/Contao/Template.php on line 298

#0 [internal function]: __error(2, 'Cannot modify h...', '/var/www/kunden...', 298, Array)
#1 system/modules/core/library/Contao/Template.php(298): header('Vary: User-Agen...', false)
#2 system/modules/core/classes/BackendTemplate.php(162): Contao\Template->output()
#3 contao/install.php(827): Contao\BackendTemplate->output()
#4 contao/install.php(220): InstallTool->outputAndExit()
#5 contao/install.php(1093): InstallTool->run()
#6 {main}


Warning: Cannot modify header information - headers already sent by (output started at /var/www/kundenprojekte/pizzasteinversand/system/helper/functions.php:70) in system/modules/core/library/Contao/Template.php on line 299

#0 [internal function]: __error(2, 'Cannot modify h...', '/var/www/kunden...', 299, Array)
#1 system/modules/core/library/Contao/Template.php(299): header('Content-Type: t...')
#2 system/modules/core/classes/BackendTemplate.php(162): Contao\Template->output()
#3 contao/install.php(827): Contao\BackendTemplate->output()
#4 contao/install.php(220): InstallTool->outputAndExit()
#5 contao/install.php(1093): InstallTool->run()
#6 {main}

Custom validators

We should add the custom validators feature. One of the ideas was to have the validators in separate classes, like this:

Form.php
/Validator
ValidatorInterface.php
MandatoryOnValidator.php
XYValidator.php
etc.

Personally, I don't think it's a good solution. It's just too much for such simple thing. In my opinion we should provide a custom validation as callbacks, with anonymous functions this should be a great thing. If somebody will need to share same validation rules across his system, then he can still provide his own class and use the callbacks.

Set formSubmit value in form->addToObject method

Hei there,

is there a reason for not setting the formSubmit value in the addToObject method of Haste\Form\Form like it is set in the generate method?

Anyhow, I solved the issue by setting that value via $this->hasteInstance->getFormId() in the template, but now I have to do that in every form template.

addFieldsFromFormGenerator not showing form

I can not use the addFieldsFromFormGenerator function to integrate forms from the Contao form generator. Using Contao 3.2.8 and Haste 4.1.0 stable build 2.

Uncommenting the following lines in Form\Form.php at row 490 solves the problem.

if (is_callable($varCallback) && !call_user_func_array($varCallback, array(&$k, &$v))) {
continue;
}

Add request token by default?

Hey,

Shouldn't we add the REQUEST_TOKEN by default if it's a post form? And add the possibility to remove it?
Otherwise we always need something like this:

$objForm->addFormField('REQUEST_TOKEN', array(
    'inputType' => 'hidden',
    'value' => REQUEST_TOKEN
));

// cc @aschempp @qzminski

ORDER BY in load_callback

We need the feature for an ORDER BY when loading the initial values because I set forceSave to true which stores my order of the chosen ID's correctly but I cannot do any FIND_IN_SET() as there's no option for that in the relation definition yet.

HasteFrom::__get($strKey) should call its parent method

Using HasteForm with Contao 3 occurs an issue with the magic __get() method because of Contao 3 "lazy loading" of the Input or Environment class.

So a default part should be added:

default:
                return parent::__get($strKey);
                break;

Unset a field

Hi,

I would like to remove a field before adding the data in the DB.

// captcha is not stored in db
$objForm->removeField('form_captcha');

But I have a query error. The field is not removed. I do not know why it does not work...

Fatal error: Uncaught exception Exception with message Query error: Unknown column 'form_captcha' in 'field list' ...

The code :

        ...

        $this->Template = new FrontendTemplate('jb_jobForm');

        // first param is the form id
        $objForm = new HasteForm('job_application', $arrFields);

        // The submit button
        $objForm->submit = $GLOBALS['TL_LANG']['MSC']['form_submit'];

        // get the form as string
        $objForm->addFormToTemplate($this->Template);


        if ($objForm->validate())
        {
            // captcha is not stored in the db
            $objForm->removeField('form_captcha');

            $arrData = $objForm->fetchAll();

            // update DB ...
        }

        ...

select menu / checkbox: no active value after reload

Select menues and checkboxes don't take the active value from the database. The select menues show always the first record after reload. Checkboxes don't show the selected boxes.
But the values in the databse are available and correct. Text fields and textarea work with field type 'default'.

/* get data from db */
$objCompany = $this->Database->prepare("SELECT * FROM tl_memo_companies WHERE member=?")->execute($userId); 

/* generate form */
$objForm = new \Haste\Form\Form('companyData','POST',function ($objHaste)
{
     return \Input::post('FORM_SUBMIT') === $objHaste->getFormId();
});

// work!
$objForm->addFormField('company_name',array(
     'label'         => $GLOBALS['TL_LANG']['tl_memo_companies']['company_name'][0],
     'default'       => $objCompany->company_name,
     'inputType'     => 'text',
));

//doesn't work:
$objForm->addFormField('sector',array(
     'label'         => $GLOBALS['TL_LANG']['tl_memo_companies']['sector'][0],
     'value'         => $objCompany->sector_de,
     'inputType'     => 'select',
     'foreignKey'    => 'tl_memo_sectors.sector_de',
));

//doesn't work:
$objForm->addFormField('subject',array(
     'label'         => $GLOBALS['TL_LANG']['tl_memo_companies']['subject'][0],
     'default'       => $objCompany->subject_de,
     'inputType'     => 'checkbox',
     'foreignKey'    => 'tl_memo_subjects.subject_de',
));


$objForm->addSubmitFormField('submit','Speichern'); 

if ($objForm->validate())
{
    $arrData = $objForm->fetchAll();

    foreach($arrData as $key => $value)
    {
        $arrDB[$key] = $value;
    }

    $this->Database->prepare('UPDATE tl_memo_companies %s WHERE member = ?')->set($arrDB)->execute($userId);
}       

/* Template */
$this->Template->form = $objForm->generate();

Option selected="selected"

Hi,

With the function generateForm() the option selected="selected" is not displaying.

It would be useful to have this option for a search form for example.

<select id="ctrl_XY" class="select" name="XY">
    <option value="value1">value1</option>
    <option selected="selected" value="value2">value2</option>
</select>

Is it possible to add this ?

Thx

{{request_token}} wird nicht generiert

Hi,

ich bin mir nicht sicher ob ich einen Fehler gemacht habe aber ich habs jetzt in 2 unabhänigen Installationen getestet.

Egal welches Formular ich mit \Haste\Form\Form erstelle, der request_token wird immer als insertTag ausgegeben {{request_token}} und schlägt damit fehl. Erstelle ich ein hidden Field und setze als default => REQUEST_TOKEN wird dieser sauber generiert.

In Contao selbst wird dies im FrontendTemplate erledigt (Zeile 98 | Contao 3.4)
$this->strBuffer = str_replace(array('{{request_token}}', '[{]', '[}]'), array(REQUEST_TOKEN, '{{', '}}'), $this->strBuffer);

Mein Fehler? Bug in Haste oder Bug in Contao?

Edit: also mit $objForm->addContaoHiddenFields(); gehts, aber im Quelltext hab ich natürlich jetzt die hidden Fields doppelt.

input type="hidden" value="swmSearch" name="FORM_SUBMIT">"
input type="hidden" value="{{request_token}}" name="REQUEST_TOKEN">"
input type="hidden" value="swmSearch" name="FORM_SUBMIT">"
input type="hidden" value="59c8b348a0594ad6221f6c5390e82534" name="REQUEST_TOKEN">"

Tableless as an option

Hi,

I would like to know how can I use this option with Haste ?

$arrField['eval']['tableless'] = TRUE | FALSE;

Thx

Related feature

When deleting an entry, the relation table doesn't get updated.

Contao form hooks

I'm wondering why the haste forms don't use the Contao hooks. It's causes problems when using extensions for forms. Thanks in advance.

Problem with "ondelete_callback"

Hi,
a question regarding the problem of the extentions haste and efg.

If these two modules are installed you cannot delete form datas within efg forms.
The reason therefore ist that ondelete_callback 'Haste\Model\Relations', 'cleanRelatedRecords' is called.
To fix this I wanted to ask whether you can do the following step:
Can you insert this code https://github.com/codefog/contao-haste/blob/master/library/Haste/Model/Relations.php#L94
into this if loop https://github.com/codefog/contao-haste/blob/master/library/Haste/Model/Relations.php#L89?

Thanks Sven

Bad value for attribute action on element form

I have enclosed Haste to the Votebox extension of Yanick and stumble across the following error:

Line number 652
<form action="' . $this->action . '" id="' . $this->strFormId . '" enctype="' . ($this->hasUploads ? 'multipart/form-data' : 'application/x-www-form-urlencoded') . '" method="' . $this->method . '">

Browser output:
<form action="" id="vb_new_idea" enctype="application/x-www-form-urlencoded" method="post">

Bad value for attribute action on element form: Must be non-empty.

Any URL. For example: /hello, #canvas, or http://example.org/. Characters should be represented in NFC and spaces should be escaped as %20.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.