Giter Club home page Giter Club logo

Comments (4)

Romik90 avatar Romik90 commented on June 27, 2024 2

Как можно отключить валидацию значений в енам полях? NotSupportedChoice мешает, желаемым поведением было бы чтобы поле не заполнялось, если в него передано некорректное значение, как было в предыдущих версиях апи

from amocrm-api-php.

Kariamba avatar Kariamba commented on June 27, 2024 1

Разобрался.
У SelectCustomFieldValueModel действительно есть метод setEnumId(). Я get_class_methods() не у того класса смотрел ).

from amocrm-api-php.

bigperson avatar bigperson commented on June 27, 2024

Можно взять за основу https://github.com/ufee/amoapi#%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%B0-%D1%81-%D0%B4%D0%BE%D0%BF%D0%BE%D0%BB%D0%BD%D0%B8%D1%82%D0%B5%D0%BB%D1%8C%D0%BD%D1%8B%D0%BC%D0%B8-%D0%BF%D0%BE%D0%BB%D1%8F%D0%BC%D0%B8

$entity->cf('Имя поля')->reset();
$entity->cf('Организация')->removeBy('name', 'ИП Петров А.А.');

$entity->cf('Имя поля')->getValue();
$entity->cf('Имя поля')->getValues();
$entity->cf('Имя поля')->getEnums();
$entity->cf('Дата')->format('Y-m-d');
$entity->cf('Дата')->getTimestamp();
$entity->cf('Организация')->getValues();

$entity->cf('Имя поля')->setEnum($enum);
$entity->cf('Имя поля')->setEnums($enums);
$entity->cf('Число')->setValue(5);
$entity->cf('Текст')->setValue('Test');
$entity->cf('Мультисписок')->reset()->setValues(['Мужская одежда', 'Аксессуары']);
$entity->cf('День рождения')->setDate('Y-m-d');
$entity->cf('Дата')->setTimestamp(14867456357);
$entity->cf('Дата')->setDate('Y-m-d');
$entity->cf('Переключатель')->enable();
$entity->cf('Переключатель')->disable();
$entity->cf('Полный адрес')->setCountry('Россия');
$entity->cf('Полный адрес')->setRegion('Чувашская республика');
$entity->cf('Полный адрес')->setCity('Чебоксары');
$entity->cf('Полный адрес')->setIndex(428000);
$entity->cf('Телефон')->setValue('987654321', 'Home');
$entity->cf('Телефон')->setValue('123456789');
$entity->cf('Email')->setValue('[email protected]');
$entity->cf('Мгн. сообщения')->setValue('bestJa', 'Jabber');
$entity->cf('Юр. лицо')->setName('Команда F5');
$entity->cf('Юр. лицо')->setAddress('РФ, ЧР, г.Чебоксары');
$entity->cf('Юр. лицо')->setType(1);
$entity->cf('Юр. лицо')->setInn(123);
$entity->cf('Юр. лицо')->setKpp(456);
$entity->cf('Организация')->addValue([
    'name' => 'ИП Петров А.А.',
    'city' => 'Москва',
    '...' => '...'
]);

from amocrm-api-php.

Kariamba avatar Kariamba commented on June 27, 2024

Подскажите, а как работать с полями типа "Список".
Я пытался по аналогии с текстовыми полями из примера работать:

// $val - ID значения списка
// $field_id - ID поля

$selectCustomFieldValueModel = new SelectCustomFieldValuesModel();
$selectCustomFieldValueModel->setFieldId($field_id);
$selectCustomFieldValueModel->setValues(
	(new SelectCustomFieldValueCollection())
		->add((new SelectCustomFieldValueModel())->setValue($val))
);
$amo_lead_fields->add($selectCustomFieldValueModel);

Но запрос не проходит валидацию: {"code":"NotSupportedChoice","path":"custom_fields_values.1.values.0.value","detail":"The value you selected is not a valid choice."}.
При этом посмотрел как запрос формируется:

 array (
          'field_id' => 1908092,
          'field_code' => NULL,
          'values' => 
          array (
            0 => 
            array (
              'value' => 4463824,
              'enum_id' => NULL,
            ),
          ),
        ),

Настораживает, что ID попал в value, а не в enum_id. Думал есть какой-то отдельный метод на добавление именно enum_id, но сделав get_class_methods() увидел только setValue().

Подскажите как передать поле типа "Список".

from amocrm-api-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.