Autofocus first field as settings option (#536)
Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
parent
94b3d26672
commit
a73badb091
|
|
@ -62,6 +62,7 @@ abstract class UserFormRequest extends \Illuminate\Foundation\Http\FormRequest
|
|||
'confetti_on_submission' => 'boolean',
|
||||
'show_progress_bar' => 'boolean',
|
||||
'auto_save' => 'boolean',
|
||||
'auto_focus' => 'boolean',
|
||||
|
||||
// Properties
|
||||
'properties' => 'required|array',
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ class Form extends Model implements CachableAttributes
|
|||
'confetti_on_submission',
|
||||
'show_progress_bar',
|
||||
'auto_save',
|
||||
'auto_focus',
|
||||
|
||||
// Security & Privacy
|
||||
'can_be_indexed',
|
||||
|
|
|
|||
|
|
@ -185,6 +185,11 @@
|
|||
label="Auto save form response"
|
||||
help="Will save data in browser, if user not submit the form then next time will auto prefill last entered data"
|
||||
/>
|
||||
<ToggleSwitchInput
|
||||
name="auto_focus"
|
||||
:form="form"
|
||||
label="Auto focus first input on page"
|
||||
/>
|
||||
</editor-options-panel>
|
||||
</template>
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ export const initForm = (defaultValue = {}, withDefaultProperties = false) => {
|
|||
closed_text:
|
||||
"This form has now been closed by its owner and does not accept submissions anymore.",
|
||||
auto_save: true,
|
||||
auto_focus: true,
|
||||
border_radius: 'small',
|
||||
size: 'md',
|
||||
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ onMounted(() => {
|
|||
console.error('Error appending custom code', e)
|
||||
}
|
||||
}
|
||||
if (!isIframe) focusOnFirstFormElement()
|
||||
if (!isIframe && form.value?.auto_focus) focusOnFirstFormElement()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->boolean('auto_focus')->default(true);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->dropColumn('auto_focus');
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue