dev-master
9999999-devTakes form fields specified through $hidden_fields and hides them from edit form.
BSD-3-Clause
The Requires
model silverstripe fields hidden
Takes form fields specified through $hidden_fields and hides them from edit form.
Takes form fields you specified through $hidden_fields and hides them from the edit form. I found if you completely remove the field then the value doesn't get saved to the database and you end up with child without a parent relationship., (*1)
Instead this extension replaces the field with a hiddenfield., (*2)
composer require "svandragt/silverstripe-hiddenfields:*"
Object::add_extension("DataObject","HiddenFieldsDataExtension");
Course.php:, (*3)
<?php class Course extends DataObject { public static $db = array( 'Title' => 'Varchar(500)', ); public static $has_many = array( 'CourseDates' => 'CourseDate', ); }
CourseDate.php:, (*4)
<?php class CourseDate extends DataObject { public static $db = array( 'StartDate' => 'Date', 'EndDate' => 'Date', ); public static $has_one = array( 'Course' => 'Course' ); public static $hidden_fields = array( 'CourseID' ); }
CourseModelAdmin.php:, (*5)
<?php class CourseModelAdmin extends ModelAdmin { public static $managed_models = array( 'Course', 'CourseDates', ); static $url_segment = 'courses'; // Linked as /admin/products/ static $menu_title = 'Course Admin'; }
Do a /dev/build and create a new course in the CMS. After saving, when accessing the CourseDates tab, you will not see the option to select the Course related to the dates (it is automatically saved from the parent - child relationship in this case)., (*6)
Takes form fields specified through $hidden_fields and hides them from edit form.
BSD-3-Clause
model silverstripe fields hidden