Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Nov 8, 2024
1 parent 7f0e787 commit f186bee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ Then we can create the form field, calling the closure as the source argument

```php
$field = DropdownField::create('MyObjectID', 'My Object', $source());
// or...
$field = ListboxField::create('MyObjects', 'My Objects', $source());
// or...
$field = CheckboxSetField::create('MyObjects', 'My Objects', $source());
```

Next, we can tell the field to use and configure quickaddnew. The first parameter is the class name of the object that will be created. The second is the $source closure Note: See QuickAddNewExtension::useAddNew() for the list of configurations parameters available. These allow you to customise the fields and required fields (for validation) for the dialog. By default the object class's getAddNewFields() or getCMSFields() methods are used
Expand All @@ -45,3 +49,10 @@ Add the field to your FieldList
```php
$fields->addFieldToTab('Root.Main', $field);
```

Advanced usage
--------

By default, the dialog will display all fields from `getCMSFields`. You may
want to implement a `getAddNewFields` that returns only a specific set of fields to display
in the creation dialog.
2 changes: 1 addition & 1 deletion src/extensions/QuickAddNewExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class QuickAddNewExtension extends Extension // phpcs:ignore
protected static $is_creating = false;

/**
* Tell this form field to apply the add new UI and fucntionality
* Tell this form field to apply the add new UI and functionality
*
* @param class-string $class - the class name of the object being managed on the relationship
* @param callable $sourceCallback - the function called to repopulate the field's source array
Expand Down

0 comments on commit f186bee

Please sign in to comment.