Re: How do I get Cake 3.1 to reply to an AJAX request without requiring a layout .ctp file?

2015-10-14 Thread Kevin Arnett
code that generated the URL:
$url = $this->Url->build(['controller' => 'Purchases', 'action' =>
'get_sales_people_select_list','_ext'=>'json']);
$url = $url . '/47';

The generated URL:
/purchases/get-sales-people-select-list.json/47

Is this not correct?

On Wed, Oct 14, 2015 at 4:40 PM, Anthony GRASSIOT 
wrote:

> Did you correctly specify the data type json in your ajax call ?
> Le 14 oct. 2015 09:02, "heavyKevy"  a écrit :
>
>> I have gone through the documentation, which is a bit too vague, and
>> tried many things, but I still am getting an error that the template file
>> is missing.
>>
>> I had this working sending back a json response in 3.0 using ext='json',
>> yet after updating to 3.1 it is broken.
>>
>> I checked the migration guide and tried changing ext  to _ext, setting up
>> the Routes with:
>> Router::extensions(['json']);
>>
>> in the controller method I am using the _serialize key which is supposed
>> to render without the template:
>> $this->set('_serialize', ['salesPeople']);
>>
>> The JsonView class does not appear to be loading and I don't see in the
>> documentation where I am supposed to set it.
>> The documentation says ' you can automatically leverage the new view
>> classes' By enabling RequestHandlerComponent in your application, and
>> enabling support for the json and or xml extensions, but I have enabled
>> it in the Initialize method of the controller and enabled the 'json'
>> extension as mentioned earlier and it is still not working.
>>
>> Here is the method in question:
>> public function getSalesPeopleSelectList() {
>> $this->request->accepts('json'); // No direct access via browser
>> URL
>> $dealerId = $this->request->params['pass'][0];
>> $this->RequestHandler->renderAs($this, 'ajax');
>> //$this->viewClass = 'Json';
>> $this->loadModel('SalesPeople');
>> $salesPeople =
>> $this->Purchases->SalesPeople->find('list')->where(['is_active'=>'1','user_id'=>$dealerId]);
>> //for salespeople options for autocomplete
>> $this->set(compact('salesPeople'));
>> $this->set('_serialize', ['salesPeople']);
>> }
>>
>>
>> When I enable the _ext = json I get the following error:
>>
>> 2015-10-14 06:57:36 Error:
>> [Cake\Controller\Exception\MissingActionException] Action
>> PurchasesController::getSalesPeopleSelectList.json() could not be found, or
>> is not accessible.
>> Exception Attributes: array (
>>   'controller' => 'PurchasesController',
>>   'action' => 'getSalesPeopleSelectList.json',
>>   'prefix' => '',
>>   'plugin' => NULL,
>> )
>> Request URL: /Subaru/purchases/get-sales-people-select-list.json/47
>> Stack Trace:
>> #0
>> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(114):
>> Cake\Controller\Controller->invokeAction()
>> #1
>> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(87):
>> Cake\Routing\Dispatcher->_invoke(Object(App\Controller\PurchasesController))
>> #2 C:\WebServer\webdocs\Subaru\index.php(42):
>> Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request),
>> Object(Cake\Network\Response))
>> #3 {main}
>>
>> What have I missed?
>>
>> --
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "CakePHP" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to cake-php+unsubscr...@googlegroups.com.
>> To post to this group, send email to cake-php@googlegroups.com.
>> Visit this group at http://groups.google.com/group/cake-php.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/31AlwVDJmv8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Cake 3 Security Component black holes add with associations

2014-09-03 Thread Kevin Arnett
No, following is the add.ctp:

echo $this->Form->input('name');
$Selected =0;
if($role != 'admin' && $role != 'prog-admin')
{
$Selected = $this->resortId;
}
echo $this->Form->input('user_id', ['title'=>'Promotion
Resort/Program','options' => $resorts, 'selected'=>$Selected]);
echo $this->Form->input('start_date');
echo $this->Form->input('end_date');
echo $this->Form->input('passes_allowed');
echo 'Use Shift and/or Control to select as many dealers as needed.';
echo $this->Form->input('users._ids', ['title'=>'Associated
Dealers','options' => $dealers]);


On Thu, Sep 4, 2014 at 4:20 AM, José Lorenzo  wrote:

> Are you creating the second control with javascript?
>
>
> On Wednesday, September 3, 2014 11:09:19 PM UTC+2, heavyKevy wrote:
>>
>>  I have promotions owned by a user
>> and associated with other users.
>>
>> The Add screen gives a Select control for selecting the owner and a
>> multi-select for selecting the associated users.
>>
>> In PromotionsTable::
>> public function initialize(array $config) {
>> $this->table('promotions');
>> $this->displayField('name');
>> $this->primaryKey('id');
>>
>> $this->belongsTo('Users', [
>> 'foreignKey' => 'user_id',
>> ]);
>> $this->belongsToMany('Users', [
>> 'foreignKey' => 'promotion_id',
>> 'targetForeignKey' => 'user_id',
>> 'joinTable' => 'promotions_users',
>> ]);
>> }
>>
>> Data saves fine if the security component is not loaded...
>> black holes the request otherwise...
>> Is this a bug or is this by design?
>>
>>  --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/yVBlSRaGTGI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.