Log message #3880938

# At Username Text
# May 26th 2016, 16:14 MarcosDantas sorry for my english
# May 26th 2016, 16:12 nemmons i'm sorry, i don't understand what you're asking. if you have an entity object called $entity and you want to unlock the 'users_id' field, you can call `$entity->accessible('users_id);`. if you want to mass-set properties to an entity, bypassing guarded fields, then you call `$entity->set($properties, ['guard' => false]);` (where $properties is an array of key-value pairs of the data you want to set)
# May 26th 2016, 16:09 MarcosDantas whats correct form?
# May 26th 2016, 16:09 MarcosDantas or view.
# May 26th 2016, 16:09 MarcosDantas wan'ted to set this on controller
# May 26th 2016, 16:08 MarcosDantas slackebot i use behavior for set users_id on relationship
# May 26th 2016, 16:06 MarcosDantas ok, but i used bake for code, and i try edit one 4 one.
# May 26th 2016, 16:05 Neon1024x Will disable the mass assignment protection
# May 26th 2016, 16:05 Neon1024x MarcosDantas, If you just set the $_accessible array to include the field as 'field' => false
# May 26th 2016, 16:05 MarcosDantas but not working...
# May 26th 2016, 16:05 MarcosDantas when save date, behavior disable guard and set users_id for company entity
# May 26th 2016, 16:05 Neon1024x greenmanspirit, Yes it is, that's the form tampering protection
# May 26th 2016, 16:04 nemmons the guard option is for when you're doing $entity->set() if you want to set data to a guarded field
# May 26th 2016, 16:04 nemmons http://book.cakephp.org/3.0/en/orm/entities.html#modifying-the-guarded-fields-at-runtime i don't think you need to pass the option array there
# May 26th 2016, 16:02 MarcosDantas hi guys
# May 26th 2016, 15:57 MarcosDantas $entity->accessible('users_id', ['guard' => false]);
# May 26th 2016, 15:56 MarcosDantas its possible?
# May 26th 2016, 15:56 MarcosDantas i cannot disable guard in behavior
# May 26th 2016, 15:32 Neon1024x Guest92387, Perhaps!
# May 26th 2016, 15:29 hmic !tell Guest92387 about ask
# May 26th 2016, 15:28 Guest92387 can help me?
# May 26th 2016, 15:28 Guest92387 im need help with behavior
# May 26th 2016, 15:28 Guest92387 Hi guys!
# May 26th 2016, 15:27 Marcos can help me?
# May 26th 2016, 15:27 Marcos im need help with behavior
# May 26th 2016, 15:27 Marcos Hi guys!
# May 26th 2016, 15:23 gigikent luv u guyz :P
# May 26th 2016, 15:22 nemmons you could also do `$this->addAssociations(['belongsTo' => ['Attacks','Sniffers']]);
# May 26th 2016, 15:21 Neon1024x $this->belongsTo('Attacks'); $this->belongsTo('Sniffers');
# May 26th 2016, 15:21 Neon1024x And I'd refactor to make each belongsTo() into it's own call, just as it is in bake
# May 26th 2016, 15:21 nemmons yeah if you want to use belongsTo you need to make 1 call per association
# May 26th 2016, 15:21 Neon1024x In which case I would summise that it doesn't take an array
# May 26th 2016, 15:20 gigikent Events is not associated with Attacks)
# May 26th 2016, 15:20 gigikent $events = $this->Events->find('all')->contain(['Attacks', 'Sniffers']);
# May 26th 2016, 15:20 Neon1024x So a typo in your query, usually in a contain() for me
# May 26th 2016, 15:19 Neon1024x gigikent, If you're in cake 3 it's Attacks not Attack
# May 26th 2016, 15:19 Neon1024x In 3.x all the options have been removed in favour of string templates
# May 26th 2016, 15:19 gigikent I have 3 tables, attacks(id), sniffers(id), events(id, attack_id, sniffer_id) What would be the correct association in EventsTable? I have $this->belongsTo(['Sniffers', 'Attacks']) but this throws this error: Events is not associated with Attack
# May 26th 2016, 15:19 VzlaCaker =(
# May 26th 2016, 15:19 nemmons doesn't look like it, not without editing the template
# May 26th 2016, 15:19 Neon1024x Edit the template :p