open-admin-org / open-admin

open-admin forked from z-song/laravel-ladmin. Removing jquery, now based on Bootstrap5, vanilla JS
https://open-admin.org
MIT License
251 stars 72 forks source link

input data using $form->html() #166

Open uluumbch opened 6 months ago

uluumbch commented 6 months ago

Help Me I want to create input using HTML $form->html() but when submitted the data is not save to database

Is anyone can try to make it work? System

RCyrix commented 6 months ago

Hi, $form->html("input name='your_html_input'>"); //Or put your html into a view and view('your-view')->render();

//Register column with form $form->hidden('your_db_column');

$form->saving(function($form){ $form->your_db_column = $form->input("your_html_input") });

just dd($form) in the saving hook and check the inputs

RCyrix commented 6 months ago

Hi there, just an update, i had to do something similar to this, i found that HTML tags are ignored, i have not yet figured out why, though select tags for example are referencable in the manner described above,

With the text what i ended up doing is writing a lil script, that on keydown it updates a hidden field, ( $form->hidden('your_db_column'); )

The value is then available in saving hook

Not sure why it does not work with text type inputs, so anything that uses text as a base, time, calendar, text, email, but it picks up on