Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add Translatable support to userforms #10

Open
wilr opened this Issue Apr 14, 2012 · 34 comments

Comments

Projects
None yet
Owner

wilr commented Apr 14, 2012

Form fields need to change from pointing at a specific parent ID to a form ID and then forms can be used on multiple pages.

oddnoc commented Jun 26, 2013

Hi @wilr -- I'm trying to wrap my head around this. Why did this work in 2.4? What changed about userforms for 3.x compatibility that broke Translatable support?

Owner

mateusz commented Jul 5, 2013

Did anyone work on this yet? If not I'll have a look.

Owner

mateusz commented Jul 5, 2013

@willr if you mean providing this functionality silently under the hood, then I don't think that would be useful - if the editor attempted to translate the EditableFormFields on the new page, he would end up editing the original form as well (not realising these are the same). Unless you mean divorcing the form builder from the page, so there is a separate section in the CMS for building forms, and then editor can hook these forms up with the UserDefinedForm pages?

As an alternative, how would you feel about instead providing a UserDefinedForm::createTranslation implementation with a deep-copy capability instead, so the form gets fully copied when a translation is made?

Owner

wilr commented Jul 5, 2013

@mateusz I was thinking about separating form building from from the page as part of it. The deep copy stuff should be there already? duplicating a page should copy the fields and rules already.

Hi Will,

this is really annoying bug, any progress here, pls.?

Owner

wilr commented Sep 16, 2013

Hi @silverstripesk, no sorry. I do not use translatable so not high on my todo list. Contributions welcome.

tzeller commented Sep 16, 2013

hi will
can we support you regarding the translatable bug?

tobias

Owner

wilr commented Sep 17, 2013

What kind of support where you thinking @tzeller. Patches welcome and I'm happy to peer review any pull requests but I have a shortage of time to sit down and work on this myself.

Hi,
This is indeed a very annoying issue. I have a 3.0.3 website up and running where it DOES work.
So it's a 3.1 thingie? Alas, my php-skills are too limited to patch it myself. Do any of you guys know someone who can solve this. I would be very grateful!
Guy

Dňa 07.10.2013 10:40, guyvanbael wrote / napísal(a):

Hi,
This is indeed a very annoying issue. I have a 3.0.3 website up and
running where it DOES work.
So it's a 3.1 thingie? Alas, my php-skills are too limited to patch it
myself. Do any of you guys know someone who can solve this. I would be
very grateful!
Guy


Reply to this email directly or view it on GitHub
#10 (comment).

Hi Guy,

we will try to patch it within your upgrades and post it to community ;)
No problem.

Best regards

Pali

memdev commented Oct 21, 2013

As a hotfix you could just remove these three lines from UserDefinedForm::getCMSFields():

/**
 * @return FieldList
 */
public function getCMSFields() {
    // call updateCMSFields after userforms
    //SiteTree::disableCMSFieldsExtensions();     <-- REMOVE or comment this line
    $fields = parent::getCMSFields();
    //SiteTree::enableCMSFieldsExtensions();      <-- REMOVE or comment this line

    ...

    //$this->extend('updateCMSFields', $fields);  <-- REMOVE or comment this line

    return $fields;
}

This avoids the issue mentioned in #128

Hope this helps someone unitl a real fix is here.

Still an issue.

Hi There,

Pretty new to Git so forgive any mistake. I'm working with UserDefinedForm I upgraded today, and guess what, I had the exact same problem as you guys. I narrowed it and I can propose a quick fix for it; I let WillR decide whether is it sufficient and robust enough. Here it is:

In the file "/userforms/code/formfields/FieldEditor.php" I change the Fields method starting on line 90 as follow:

(Please note that I am testing whether the current record has the expected many relationship.)

/**
* Return the fields.
*
* @return RelationList
*/
public function Fields() {

    if($this->form && $this->form->getRecord() && $this->name) {
        $relationName = $this->name;
                    $record = $this->form->getRecord(); // <--- Youss: Needed This for the next line

                    if($record->has_many($relationName))  // <--- Youss: This if is the main change
                    {
                        $fields = $record->getComponents($relationName);

                        if($fields) {
                                foreach($fields as $field) {
                                        if(!$this->canEdit() && is_a($field, 'FormField')) {
                                                $fields->remove($field);
                                                $fields->push($field->performReadonlyTransformation());
                                        }
                                }
                        }

                        return $fields;
                    }
    }
}

Cheers from France,

Youss

Thank you for your email,

Kyle is no longer with fatfish, your email has been forwarded to Paul Bennett studio manager.

if your request is urgent please call Paul on the below
T 03 8696 7027 M 0423 781 873
paul.bennett@fatfish.com.au

Regards

fatfish

Hi again,

Another problem raised after solving the first one: once you click on a translated suggestion page, no submission are shown even if they are in the Database. The problem is that the updateCMSFields tries to manipulate the submissions to add the original field which does not exist for the submissions as each language has its own submissions.

The solution is to move up the line $this->extend('updateCMSFields', $fields); right before we add the submissions tab. Doing this everything is fine for all languages. Here is the code starting on line 156 in the file "/userforms/code/model/UserDefinedForm.php":

    $submissions->setConfig($config);

            $this->extend('updateCMSFields', $fields);  // <--- This line has been moved up.

            $fields->addFieldToTab("Root.Submissions", $submissions);
    $fields->addFieldToTab("Root.FormOptions", new CheckboxField('DisableSaveSubmissions',_t('UserDefinedForm.SAVESUBMISSIONS',"Disable Saving Submissions to Server")));

    return $fields;

Now this module is fully working for me. on all languages.

Cheers,

Youss

Worked for me, this is a pretty substantial bug for sites that use the translatable module.

Is this solution already merged in the latest userforms repo or is it still a bug?

Still not fixed.

@GitYouss thanks for that solution.

It is still not fixed though. Really annoying having to edit the actual module.

Still not fixed? @memdev's solution seems to work

Not fixed yet. I impelemented @GitYouss solution and that prevents the error and creates the translated page, but form fields are not transfered so fields and rules have to be added per language... this is a really annoying bug.

Hi there, I need help with this one too!

I have a rather large multilanguage Website (with Translatable), just currently updated from SilverStripe 2.4 to 3.1
Got a message today from the people of the netherlands, that their contact form has german field names... (same with other languages)
[I think before saving the translated Pages manually, the fields were displayed in the right language?]

-> with the fixes explained here I can open the backend again, but can't add or edit Form Fields for all other languages but the default. Only the fields in the default locale are displayed and edited.

This really is a major problem for me so I am thankful for every hint !
Maybe until a fix is ready, a note in the README about this module incompability would be a good thing.

It was fixed in SS3.1.16 but translatable and userforms don't play nice in SS3.2

Contributor

tractorcow commented Jan 21, 2016

Userforms has changed substantially over the last year, and since the release of framework 3.2 that has also had a lot of changes made. I think we need to agree on a set of expected behaviour for userforms / translatable, and re-test on the newer userforms.

Userforms should work as well in 3.2 as it does in 3.1, so I'm interested in seeing where the framework version introduces specific bugs.

However, it is likely that we will be fixing this in the 3.x version of userforms, not 2.x, so users might have to upgrade if they are on the older version, I'm afraid.

It does indeed work with 3.2. It's the combination userforms-translatable that doesn't work in 3.2 so for a project that i had to finish today, i went for 3.1.16 with userforms and translatable.

What exactly is the problem with userforms 2 and translatable with silverstripe 3.2?
I have just updates some projects with that combination...

Using userforms 2 with translatable is ok with the fix in this thread. SS3.1 with userforms 3 and translatable work out of the box. SS3.2 with userforms 3 and translatable don't play nice. (didn't make a screenshot of the error ... shame on me)

...sorry, I meant userforms 3, (the current version with ths EditableFormFields in a GridField)

Contributor

tractorcow commented Jan 24, 2016

Using userforms 2 with translatable is ok with the fix in this thread. SS3.1 with userforms 3 and translatable work out of the box. SS3.2 with userforms 3 and translatable don't play nice. (didn't make a screenshot of the error ... shame on me)

That's good to know... inter-version compatibility can be finicky can't it?

SS3.2 with userforms 3 and translatable don't play nice.

We'll probably focus our attention on fixing this first.

I tested SS3.3 rc2 and Userforms and translatable worked out of the box.
It would be nice though if forms and settings would be copied too so user doesn't have to recreate the form for each language, but i think that's an issue for translatable instead of userforms

Contributor

tractorcow commented Feb 21, 2016

Has anyone used fluent with userforms?

Yes, I have (min) 1 project with fluent and userforms... just looking into it

Project has been upgraded to SilverStripe 3.2.1.
Fluent, Userforms, seems to work without problems, (just saved a field and the page -> english is still english, german still german)

Contributor

tractorcow commented Feb 21, 2016

Yay. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment