1

So I've been breaking my head trying to figure this out. I'm working on a contact form plugin. Basically I'm coping exact same code craft uses to create form "fields". I have validation working like it should. And I have 2 required fields that should return error messages. But when I try to:

craft()->urlManager->setRouteVariables(array(
  'field' => $field
));

And in the template file {{ field }}, I get.. Variable "field" does not exist

I can't seem to get the value to populate on the form nor display the errors because of this. Anyone had problems like this before?

Here's my files: https://gist.github.com/owldesign/e01b49fdb1da3ef23ef2

Sorry for weird file delivery.. this comment won't let me post more than 2 links.

Please let me know if you guys need more from me? Thanks.

Edit: Repo https://github.com/owldesign/FormBuilder

| improve this question | | | | |
  • can you just push up a repo fo the plugin to github? – Luke Holder Nov 6 '14 at 4:54
  • here's a repo to the plugin github.com/owldesign/FormBuilder – Vadim Goncharov Nov 6 '14 at 5:49
  • does the error happen when first opening the field _edit screen, or only after making a new field with errors. – Luke Holder Nov 6 '14 at 6:20
  • Error happens when I'm making the new field. I can't get the error messages from form validation to come through to the template. The flash message comes through but the variable "field" isn't coming through to the _edit.html template from the actionSaveField in the controller. basically I'm trying to pass variable "field" to the _edit.html template from the controller using the setRouteVariables(), but it doesn't seem to work :( – Vadim Goncharov Nov 6 '14 at 6:59
  • Have you tried moving the part where you return craft()->urlManager->setRouteVariables(); into the else statement along with the craft()->userSession->setError(Craft::t('Field Not Saved.')); part and then remove the return bit? This is how I have done this in the past and things return fine. – Alec Ritson Nov 6 '14 at 9:09
1

I have finished the plugin, with much success, if you wondering you can see it here https://github.com/roundhouse/FormBuilder-Craft-CMS

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.