?
avatar horvathcsabazoltan
horvathcsabazoltan
21 Jan 2019

Steps to reproduce the issue

// I used a ListModel in the display() of a HtmlView. 
$model = $this->getModel('mymodelname'); 

$model->setState('list.limit', '0');

// returns the default setting instead of the value I set on previous line
$listLimit = $model->getState('list.limit'); 

Expected result

$listLimit should be 0

Actual result

$listLimit is the default setting

System information (as much as possible)

Joomla 3.8.12 on XAMPP (Windows 10)
The same behavior is suspected in newer versions on any platform

Additional comments

I guess the setState() method shouold call populateState() if internal state is not set - just like in getState().

I don't want to overwrite the default setting by overwriting the model's populateState(), because I needed all the items from the model in this view only.

avatar horvathcsabazoltan horvathcsabazoltan - open - 21 Jan 2019
avatar joomla-cms-bot joomla-cms-bot - change - 21 Jan 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 21 Jan 2019
avatar SharkyKZ
SharkyKZ - comment - 21 Jan 2019

You have a syntax error (missing quote):

$model->setState('list.limit, '0');

And you have to pass the property name (list.limit) to getState():

$listLimit = $model->getState('list.limit'); 
avatar horvathcsabazoltan horvathcsabazoltan - change - 21 Jan 2019
The description was changed
avatar horvathcsabazoltan horvathcsabazoltan - edited - 21 Jan 2019
avatar horvathcsabazoltan
horvathcsabazoltan - comment - 21 Jan 2019

I've edited my comment, so these errors are gone. Thanks @SharkyKZ for pointing it out.

avatar SharkyKZ
SharkyKZ - comment - 21 Jan 2019

Does your issue still remain?

avatar horvathcsabazoltan
horvathcsabazoltan - comment - 21 Jan 2019

Yes. I did not copy the code, I typed it in here. My original code did not contain these typos. Sorry for that.

avatar ReLater
ReLater - comment - 21 Jan 2019

Joomla 3.8.12 on XAMPP

The current Joomla version is 3.9.2. You should update you're Joomla and test again.

avatar horvathcsabazoltan
horvathcsabazoltan - comment - 23 Jan 2019

I've updated to Joomla 3.9.2 but the problem is still there.

Sorry for the delay.

avatar franz-wohlkoenig franz-wohlkoenig - change - 4 Mar 2019
Status New Information Required
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 4 Mar 2019

@HLeithner can you please comment?

avatar HLeithner
HLeithner - comment - 4 Mar 2019

If the Model is new you have to first get the State and then you can change the state, don't ask me why thats Joomla behavior.

simple make $model->getState(); before you make the setState call

avatar joomla-cms-bot joomla-cms-bot - change - 16 Mar 2019
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2019-03-16 11:30:33
Closed_By joomla-cms-bot
avatar franz-wohlkoenig franz-wohlkoenig - change - 16 Mar 2019
Closed_By joomla-cms-bot franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - close - 16 Mar 2019
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 16 Mar 2019

Closed as Solution provided above. Please reopen if i misunderstood.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23611.

Add a Comment

Login with GitHub to post a comment