Hiding the Save Button on Edit

churari

New Member
I have a form that when a change is made to the data I want the user to only be able to "Copy as New" to save a new instance of the form.

If I toggle the save button to hidden then it doesn't show up in the "New" form (can't add a new form).

My thought is to hide the save button with javascript, but I can't seem to figure out how to access that element. I am adding javascript to an element on load.

This works to access another field:
var market = Fabrik.getBlock('form_1').elements.get('cpm___market');
market.hide();

var saveButton = Fabrik.getBlock('form_1').elements.get('Submit');
saveButton.hide();

Inspecting the Save button element:
<button type="submit" class="btn btn-primary button save" name="Submit">Save</button>

Is the elements.get using the id attribute and that is why I can't access the Submit? If so, how can I access it?

Also, any better thoughts on how to accomplish this?

Thanks.
 
To clarify,

This works to access another field:
var market = Fabrik.getBlock('form_1').elements.get('cpm___market');
market.hide();

This does not work:
var saveButton = Fabrik.getBlock('form_1').elements.get('Submit');
saveButton.hide();
 
I agree with @troester , best to do this with a custom template.

But just for completeness ... the action buttons are not "elements", in the Fabrik sense, so they aren't in the block's elements object. They are just HTML form buttons. So you'd get them with a normal DOM selector. Like ...

Code:
Fabrik.getBlock('form_5').form.getElement('button.save').hide();

... or ...

Code:
document.id('form_5_1').getElement('button.save').hide();

... or whatever your prefered method for getting the form DOM element is, form which you can then select the submit button.

-- hugh
 
Thank you Hugh, that was what I was looking for. I agree with the css concept as well, but for this application the javascript was what I was looking for. Sorry for the delayed response, the emails went into my spam folder.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top