2
Assuming a form was loaded with 10 text fields with value 1, and the user modified one of these to 0.
When submitting the form, there is something 'native' that identifies it had some change in the value of its fields ?
I want this to differentiate the shooting of an event when the user did or did not make any modifications to the open edit form.
Currently I use a very extensive process for this, when submitting, I receive all variants of the input, I search the data that was in the database, compare field to field to know if there was modification and define which event will be triggered, I think there should be a more efficient way, but I couldn’t find.
I wanted something native or that if naturally for the reason:
I do not write events for a submission, I own a framework with abstract event that does the whole process, since the validation, setar mascaras, concatenation and submission of any form (Since the form has also been generated by the framework), the solution needs to be something that I can convert into something universal, otherwise I cannot implement in the framework.
Example of rendering:
$campo = $VIDB_input->field('campo')->mask('mascara_que_eu_quiser')->type('text')->validator('validacao_que_eu_quiser')->additional_classnames('classnames_que_eu_quiser')->value($data['valor_trazido_do_bd'])->datepicker(false)->dateranger(false)->input(0);
$form_group = $VIDB_form_group->group_cols(12)->input($campo)->input_cols(12)->label('Campo: ')->label_cols(12)->form_group(0);
$submit = $VIDB_button->color('primary')->content('Salvar edições')->addicionalClassnames('pull-right')->event('submit_fake_form|caller|geralOperationalCompanies|save_edited|sectorGeral|closeClosestModalOnSuccess|json|primary-modal|SweetAlertByResponse')->event_post_content(null)->type('submit')->button(0);
$form = $VIDB_fake_form->classnames()->content($form_group.$submit)->form(0);
This code, it does the whole process of:
Render the form, concatenate the data, paste the mask into the input, validate real-time client-side, validate server-side and respond and submit the form, I would need to somehow also be able to make this comparison something global.
Not native. You can generate a JSON at page startup and compare against that JSON.
– Sergio
You say store (kk) a json with the values in the graph rendering and check before submitting?
– AnthraxisBR
@Anthraxisbr Yes, for example. If you are more specific with examples of what kind of form it is we can have other ideas/solutions
– Sergio
@Diegosantos if the user changes and then switches back to the original will give a false positive.
– Sergio
@Sergio I’m going to supplement the question, because there’s a little flaw in that because I use a framework of my own
– AnthraxisBR