Commit Graph

122 Commits

Author SHA1 Message Date
Nathan van der Werf 62c59a4903 Refactor ternary operators to null coalescing operators 2018-08-15 19:15:13 +02:00
Nathan van der Werf a3d7a028b4 Replace is_null with "=== null" comparison 2018-08-15 18:54:46 +02:00
Nathan van der Werf 123145fd54 Remove unnecessary parentheses 2018-08-15 18:49:52 +02:00
Nathan van der Werf 3a918ad200 Remove "null" assignments 2018-08-15 18:33:24 +02:00
Alexander Shapoval 1e7c3691e7 Cast outside field config to array (#3670)
This is necessary to enable the setting of tabs for SECTION_OUTSIDE: http://octobercms.com/docs/backend/forms#form-tab-options. Credit to @ebashu-on-holidays
2018-08-06 10:49:19 -06:00
Luke Towers 014bac1232
Simplify 51b6f64418
Simplifies 51b6f64418 by using the pre-existing HTML array name parsing functionality.
2017-11-02 13:13:08 -06:00
Luke Towers 51b6f64418
Convert field name to dot syntax before checking validation rules
Converts a field name in the form of `model_json_attribute[subproperty]` to the dot syntax version used by validation rules `model_json_attribute.subproperty` for more accurate checking of the validation rules in the form widget.
2017-11-02 12:35:50 -06:00
Samuel Georges cd76f2e04f Field definition should override magic 2017-09-13 14:29:42 +10:00
Samuel Georges c3570ffd7e The event emitter should not be a dependency
Fixes #2938
2017-06-23 08:11:41 +10:00
Samuel Georges 9eb0cc24ae Opens a channel for model to talk with form widget
.. and controller and beyond.
2017-06-17 21:20:34 +10:00
Samuel Georges b841f9e066 {@inheritDoc} -> @inheritDoc 2017-03-16 06:26:14 +11:00
Samuel Georges 5f91c45f79 Implement disabled support for some form widgets
Recompile assets
Fixes #2749 (Media Finder)
Fixes #2750 (File upload)
Fixes #2751 (Rich Editor)
Refs #2724
2017-03-14 13:52:47 +11:00
Samuel Georges e7fa4b832a Rollback 84b533454e
See #2749, #2750 & #2751 on notes for how to better handle this. Put simply, the control of disabled VS previewMode should be given to the individual form widget, as opposed to the spawning parent.
2017-03-14 06:49:33 +11:00
Luke Towers 84b533454e Allow FormWidgets to be disabled like regular FormFields
Adds support for the `disabled` property to FormWidgets so that they will match the behaviour present in regular FormFields. Fixes #2724 and a personal annoyance of mine :)
2017-03-11 02:12:47 -06:00
Samuel Georges 0a2b343047 Simplify system events
This pipes all event calls through a new EventEmitter trait, which substitutes the October Rain event emitter trait. The view event has been moved to this trait also.
Pass some variables by reference to allow multi-extension.
Fixes #2420
2016-12-10 09:02:06 +11:00
Samuel Georges f771887ee5 When refreshing fields, forceFill is a bit too flaky
- Using a proxy field would populate a relation with an array of attributes, this is not good or consistent. Instead the FormModelSaver trait is used to bring the behavior in line with FormController and others. This should improve consistency in the behavior and developer expectations.

- The noticeable difference will be that relations and their values are now set by the postback data where possible. In cases where this is undesirable -- eg: updating a relation triggers proxy fields to update with existing values, when they should seed from the relation instead (desire to lose prior changes) -- the formExtendRefreshData controller override can be used to prune the existing values from the dataset, where they will then be seeded from the model as normal.

- Also the $data property is only rebuilt if it differs from the model. Previously it would corrupt the model-based dataset by converting to an array then back to an object. If the two objects are the same, they will be passed by reference and values will replicate this way.
2016-11-30 07:08:12 +11:00
Samuel Georges 50d3ffb035 Halycon models do not declare forceFill
Only bind purgeable fallback event once (only needed once)
Refs https://github.com/rainlab/translate-plugin/issues/54#issuecomment-256067096
2016-11-05 10:59:53 +11:00
Samuel Georges 7b0f33e9b3 Adds an isNested flag to Form widget
This is useful when a form renders another form inside, specifically the repeater. In these cases the model and data will diverge, and it also provides an opportunity to not apply extension logic to nested form fields.
Fixes #2257
2016-11-05 09:53:23 +11:00
Samuel Georges 9b5851fbd5 Improves exception handling for invalid model resolver
A more specific error message is now shown when trying to resolve a model from an invalid source (eg: an array)
Fixes #2354
2016-09-18 13:44:13 +10:00
Samuel Georges c70db75d38 Pass the data set along with getOptions methods
This is useful when the model is unreliable, because it is not always populated with the relevant data set. This argument is only needed in edge cases, like when using a repeater or other split class<->data scenarios
Refs #2235
2016-07-23 15:16:57 +10:00
Samuel Georges bcff1d3ecd Widget classes are now extendable
Fixes #2078
Fixes #1586
2016-06-15 17:10:46 +10:00
Samuel Georges cb86e655dd Fixes disabled relation nulling value
Just like DatePicker, relation and even regular fields should omitted from the data set
The same logic should apply to hidden fields
Fixes #1827
Recompile assets
2016-05-15 06:47:28 +10:00
Samuel Georges 5400ec7d2d Complete taglist form widget 2016-05-10 06:02:35 +10:00
Samuel Georges 5d27682f25 Create new TagList form widget (Experimental)
Update Select2 to latest
2016-05-08 17:43:21 +10:00
Samuel Georges 0504da41f2 Add hasFields methods
formHasOutsideFields, formHasPrimaryTabs + formHasSecondaryTabs
2016-04-23 05:13:08 +10:00
Samuel Georges 808c8f0ca4 Minor tidy and rollback from #1720 2016-02-13 14:41:17 +11:00
Joshua Wilson 6f3d7a58f2 Phpdoc cleanup for System\Traits
removed in WidgetMaker trait

phpdoc cleanup of backend traits and classes

Minor fix for cases when file is not found
2016-02-13 14:06:50 +11:00
Samuel Georges e367febb93 Roll back some stuff from #1704 2016-02-13 13:18:48 +11:00
Alwin Drenth 386f958b6e Code improvements and added proper PhpDoc 2016-02-13 13:08:30 +11:00
Pásztor Gábor 31457bd2ee Cleanup 2016-01-15 10:20:57 +01:00
Samuel Georges af657e9399 Fixes #1042 - remove fillable constraint on models when saving
Form fields are already constrained by their fields.yaml definition (values not defined in the yaml will not be saved) so we don't need to double dip by enforcing fillable too.
2015-10-17 11:41:40 +11:00
Samuel Georges ef22ac934d DRY up code from #1504 2015-10-17 10:16:49 +11:00
Samuel Georges b7505a2cd7 Returning save data now depends on form fields, so they should always be defined 2015-10-05 18:00:01 +11:00
Samuel Georges 3a7e1d6d31 Fixes #1480 - Allow postback key names to use dots 2015-10-05 12:11:25 +11:00
Samuel Georges a636dd1ad8 Form widgets returns data only if it has a field definition 2015-09-26 11:41:02 +10:00
Samuel Georges fc04bd1b4c Added new makeFormWidget() method to WidgetMaker for rendering form widgets individually 2015-08-07 19:06:04 +10:00
Samuel Georges b010732796 These methods should be protected, update client lang 2015-08-04 10:01:17 +10:00
Samuel Georges 846feb6a33 FileUpload now triggers dependsOn event
form.beforeRefresh event now uses dataholder pattern
Improve exception handling in ControllerBehavior
2015-07-18 08:50:31 +10:00
Samuel Georges be05899a52 Outside fields don't use tabs 2015-05-21 22:55:08 +10:00
Samuel Georges c4027b8bc6 Added a defaultFrom option to form fields
Default context of manage and pivot forms is now create and update respectively, instead of the old value relation
2015-03-28 16:14:22 +11:00
Samuel Georges a1ac5edbf7 Various minor fixes and improvements 2015-03-18 19:28:14 +11:00
Samuel Georges c6bfd5d01c Move this logic to no longer depend on AR model 2015-03-10 09:34:59 +11:00
Samuel Georges 3ecdf2c74b Fixes #977 - Look to related models for getting dropdown-type options 2015-03-07 13:14:13 +11:00
Samuel Georges 668457b4e6 Updated deprecated references
Str::evalHtmlId -> October\Rain\Html\Helper::nameToId
Str::evalHtmlArray -> October\Rain\Html\Helper::nameToArray
Str::stripHtml -> October\Rain\Html\Helper::strip
Str::limitHtml -> October\Rain\Html\Helper::limit
Str::cleanHtml -> October\Rain\Html\Helper::clean
2015-03-07 12:48:39 +11:00
Samuel Georges 507bfab768 !!! *BREAKING*: Form widget base class no longer takes a model as the 2nd argument, it should be passed as `model` in the configuration instead. 2015-03-06 20:37:05 +11:00
Samuel Georges f869b8cc94 Gives FormWidgets the ability to say: "No labels, please"
ping @keiosweb
2015-03-03 20:24:14 +11:00
Samuel Georges 1ab8858271 Minor touch ups 2015-03-03 18:38:36 +11:00
Samuel Georges f9e287e173 Refactor form widget to use an approach much like ReportContainer 2015-02-28 13:37:06 +11:00
Samuel Georges 85c47c4e01 public -> protected $defaultAlias 2015-02-28 12:43:53 +11:00
Samuel Georges 5784417862 Document widget accepted config
These definitions don't serve a function other than helping developers
2015-02-28 11:50:27 +11:00