-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #7987 - allow toggle of required/optional in custom fields/fiel…
…dsets Signed-off-by: snipe <[email protected]>
- Loading branch information
Showing
3 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,12 +189,51 @@ public function associate(Request $request, $id) | |
} | ||
} | ||
|
||
$results = $set->fields()->attach(Input::get('field_id'), ["required" => ($request->input('required') == "on"),"order" => $request->input('order', 1)]); | ||
$results = $set->fields()->attach($request->input('field_id'), ["required" => ($request->input('required') == "on"),"order" => $request->input('order', 1)]); | ||
|
||
return redirect()->route("fieldsets.show", [$id])->with("success", trans('admin/custom_fields/message.field.create.assoc_success')); | ||
} | ||
return redirect()->route("fieldsets.show", [$id])->with("error", 'No field selected.'); | ||
|
||
|
||
} | ||
|
||
/** | ||
* Set the field in a fieldset to required | ||
* | ||
* @author [A. Gianotto] [<[email protected]>] | ||
* @since [v5.0] | ||
*/ | ||
public function makeFieldRequired($fieldset_id, $field_id) | ||
{ | ||
|
||
$this->authorize('update', CustomFieldset::class); | ||
$field = CustomField::findOrFail($field_id); | ||
$fieldset = CustomFieldset::findOrFail($fieldset_id); | ||
$fields[$field->id] = ['required' => 1]; | ||
$fieldset->fields()->syncWithoutDetaching($fields); | ||
|
||
return redirect()->route('fieldsets.show', ['fieldset' => $fieldset_id]) | ||
->with("success", trans('Field successfully set to required')); | ||
|
||
} | ||
|
||
/** | ||
* Set the field in a fieldset to optional | ||
* | ||
* @author [A. Gianotto] [<[email protected]>] | ||
* @since [v5.0] | ||
*/ | ||
public function makeFieldOptional($fieldset_id, $field_id) | ||
{ | ||
$this->authorize('update', CustomFieldset::class); | ||
$field = CustomField::findOrFail($field_id); | ||
$fieldset = CustomFieldset::findOrFail($fieldset_id); | ||
$fields[$field->id] = ['required' => 0]; | ||
$fieldset->fields()->syncWithoutDetaching($fields); | ||
|
||
return redirect()->route('fieldsets.show', ['fieldset' => $fieldset_id]) | ||
->with("success", trans('Field successfully set to optional')); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters