? Success

User tests: Successful: Unsuccessful:

avatar grillkoning
grillkoning
6 Sep 2018

Pull Request for Issue #21867.

Summary of Changes

to make joomla's admin model aware of subforms so you can actually handle them in seperate tables with their corresponding model

Testing Instructions

use a subform to add a row

Expected result

some DB-table has a row added which is handled by default CMS functions

Actual result

the row gets stashed away in a json field making it unpractical for sorting, searching, ACL, and just about anything

Documentation Changes Required

tbd

Example usage

Instead of extending \Joomla\CMS\MVC\ModelAdminModel ; extend this class to have your form handle subforms with their own respective models and forms

Off course you'll need to provide the model and form you want your subform to use. So in the example below you'd provide:

/**
 * Model for a list of History items
 *
 * @since 0.0.1
 */
class AmberModelHistories extends ListModel
{
// as you would when creating a listview like normal 
}

snippet from example form .xml:

<field
	name="histories"
	type="subform"
	formsource="/administrator/components/com_amber/models/forms/histories.xml"
	multiple="true"
	layout="joomla.form.field.subform.repeatable-table"
	/>

content of histories.xml:
note the fieldgroup name which needs to match the name of the subform

<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldgroup name="histories">
		<field
				name="historyID"
				type="hidden"
				/>
		<field
				name="resourceID"
				type="resource"
				label="COM_AMBER_RESOURCE_TITLE_LABEL"
				description="COM_AMBER_RESOURCE_TITLE_DESC"
				class="inputbox"
				/>
		<field
				name="difQty"
				type="number"
				label="COM_AMBER_QUANTITY_LABEL"
				description="COM_AMBER_QUANTITY_DESC"
				class="inputbox"
				/>
</fieldgroup>
				
</form>

the controller for the subform:
/administrator/compontents/com_amber/controllers/histories.php

class AmberControllerHistories extends AdminController
{

	public function getModel($name = 'History', $prefix = 'AmberModel', $config = array('ignore_request' => true))
	{
		$model = parent::getModel($name, $prefix, $config);
                return $model;
	}

avatar grillkoning grillkoning - open - 6 Sep 2018
avatar grillkoning grillkoning - change - 6 Sep 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 6 Sep 2018
Category Libraries
avatar grillkoning grillkoning - change - 6 Sep 2018
Title
Create AwareModel.php (#1)
Create AwareModel.php
avatar grillkoning grillkoning - change - 6 Sep 2018
Title
Create AwareModel.php (#1)
Create AwareModel.php
avatar grillkoning grillkoning - edited - 6 Sep 2018
avatar grillkoning grillkoning - change - 6 Sep 2018
Labels Added: ?
avatar franz-wohlkoenig franz-wohlkoenig - change - 7 Sep 2018
The description was changed
avatar joomla-cms-bot joomla-cms-bot - edited - 7 Sep 2018
avatar joomla-cms-bot joomla-cms-bot - edited - 7 Sep 2018
avatar joomla-cms-bot joomla-cms-bot - edited - 7 Sep 2018
avatar joomla-cms-bot joomla-cms-bot - change - 7 Sep 2018
Title
Create AwareModel.php
Create AwareModel.php
avatar franz-wohlkoenig franz-wohlkoenig - change - 7 Sep 2018
The description was changed
avatar joomla-cms-bot joomla-cms-bot - edited - 7 Sep 2018
avatar joomla-cms-bot joomla-cms-bot - edited - 7 Sep 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 7 Sep 2018
The description was changed
avatar joomla-cms-bot joomla-cms-bot - edited - 7 Sep 2018
avatar joomla-cms-bot joomla-cms-bot - edited - 7 Sep 2018
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 7 Sep 2018

@grillkoning i changed your Comment to be more readable and linked to Issue.

avatar zero-24
zero-24 - comment - 7 Sep 2018

@grillkoning please take a look into the drone / PHPCS reports: http://ci.joomla.org/joomla/joomla-cms/9814/4

avatar laoneo
laoneo - comment - 11 Sep 2018

Can you extend the description of this pr what you have in mind with it and a code example? It will be then easier to review.

avatar grillkoning grillkoning - change - 11 Sep 2018
The description was changed
avatar grillkoning grillkoning - edited - 11 Sep 2018
avatar grillkoning grillkoning - change - 11 Sep 2018
The description was changed
avatar grillkoning grillkoning - edited - 11 Sep 2018
avatar grillkoning
grillkoning - comment - 11 Sep 2018

thanks to all of you for your comments and attention. hopefully this will grow to be a useful feature to many.

avatar laoneo laoneo - change - 23 Mar 2022
Labels Added: ?
Removed: ?
avatar laoneo
laoneo - comment - 28 Mar 2022

Sorry it took so long to respond. As this is a nice addition for the MVC API, it is a new feature which should be adapted Joomla 4. Can you rebase the pr to the 4.2-dev branch? In the meantime I'm closing the pr, when ready please reopen again so we can leave feedback. Thank you very much for your contribution and help making Joomla better.

avatar laoneo laoneo - change - 28 Mar 2022
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2022-03-28 06:27:47
Closed_By laoneo
avatar laoneo laoneo - close - 28 Mar 2022

Add a Comment

Login with GitHub to post a comment