mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-26 20:56:48 +00:00
Nested forms are not valid HTML and we were submitting the wrong authenticity token to Rails when updating the enterprise. I inverted the hierarchy of the form and the panels. The menu and tab-panel structure now sits above and the enterprise edit form is nested within. The current structure is not ideal but it's only a transition phase. I'm expecting the page to get re-designed at some point and re-writen without AngularJS.
15 lines
866 B
Plaintext
15 lines
866 B
Plaintext
-# Not all inputs are ng inputs, they don't make the ng-form dirty on change.
|
|
-# ng-change is only valid for inputs, not for a form.
|
|
-# So we use onchange and have to get the scope to access the ng controller
|
|
= form_for [main_app, :admin, @enterprise], html: { name: "enterprise_form",
|
|
onchange: "angular.element(enterprise_form).scope().setFormDirty()",
|
|
oninput: "angular.element(enterprise_form).scope().setFormDirty()",
|
|
"ng-controller" => 'enterpriseCtrl',
|
|
"ng-cloak" => true } do |f|
|
|
|
|
%save-bar{ dirty: "enterprise_form.$dirty", persist: "true" }
|
|
%input.red{ type: "button", value: t(:update), "ng-click": "submit()", "ng-disabled": "!enterprise_form.$dirty" }
|
|
%input{ type: "button", "ng-value": "enterprise_form.$dirty ? '#{t(:cancel)}' : '#{t(:close)}'", "ng-click": "cancel('#{main_app.admin_enterprises_path}')" }
|
|
|
|
= render 'form', f: f
|