Git Product home page Git Product logo

Comments (7)

qzminski avatar qzminski commented on August 29, 2024

No idea what could be wrong. Does echo $objForm->generateForm() also outpus the wrong form?

from contao-haste.

lionel-m avatar lionel-m commented on August 29, 2024

I inserted this function in the code and it returns me the correct form !

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

        echo $objForm->generateForm() ;

And $this->Template = jb_jobForm ( FrontendTemplate Object ( [strTemplate:protected] => jb_jobForm)

But I have the first form in the frontend... The first overwrites the second.

I use this code on each template

<div class="form">
        <form action="<?php echo $this->action; ?>" method="post">
                <div class="formbody">
                    <input type="hidden" name="FORM_SUBMIT" value="<?php echo $this->formId; ?>" />
                    <input type="hidden" name="REQUEST_TOKEN" value="{{request_token}}" />

                    <table summary="Form fields">
                        <?php foreach ($this->fields as $objWidget): ?>

                            <?php echo $objWidget->parse(); ?>

                        <?php endforeach; ?>
                    </table>

                    <div class="submit_container">
                        <input type="submit" class="submit" value="<?php echo $this->submit; ?>" />
                    </div>
                </div>
        </form>
    </div>

from contao-haste.

lionel-m avatar lionel-m commented on August 29, 2024

In the second form I use a table. We can see with Firebug that has not worked well and the formId is the first...

firebug

from contao-haste.

qzminski avatar qzminski commented on August 29, 2024

I think there is some mistake in your code. Maybe try to do the following:

$objTemplate = new FrontendTemplate('jb_jobForm');

// Initialize form, etc.

$objForm->addFormToTemplate($objTemplate);
$this->Template = $objTemplate;

from contao-haste.

lionel-m avatar lionel-m commented on August 29, 2024

No result...

I use three forms with Haste and if I remove the first, the other forms work perfectly. The method for changing the template is the same...

Thank you for the help.

from contao-haste.

qzminski avatar qzminski commented on August 29, 2024

I suggest to make independent templates for each form. This way you will avoid strange errors like above.

$objTemplateSearch
$objFormSearch
// ...
$objTemplateJob
$objFormJob

// And in the main template, depending on the situation:
$this->Template->form = $objTemplateSearch->parse();

from contao-haste.

lionel-m avatar lionel-m commented on August 29, 2024

Hi,

I found a solution by replacing in the main template :

$objForm->addFormToTemplate($this->Template);

With

$this->Template->form = $objForm->generateForm();

It works...

Thanks

from contao-haste.

Related Issues (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.