Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

condition options takes no effect for related models attributes in ngRestExtraAttributeTypes #189

Open
Webkadabra opened this issue Jul 17, 2018 · 0 comments
Labels

Comments

@Webkadabra
Copy link
Contributor

condition option does not work in ngRestExtraAttributeTypes for values of related models. Code:
Product.php:

public function ngRestExtraAttributeTypes() {
        return [
            'shippingConfig' => 'angular', // MUST BE `angular`, because `hidden` would not send values to client
            'shippingConfig.is_tilt_allowed' => ['toggleStatus'],
            'shippingConfig.weight' => ['number'],
            'shippingConfig.length' => ['number'],
            'shippingConfig.width' => ['number'],
            'shippingConfig.height' => ['number', 'condition' => '{is_shipping_enabled}==1'],
        ];
    }

   public function getShippingConfig() {
        return $this->hasOne(ShopProductShippingConfig::class, ['product_id' => 'id']);
    }

public function ngRestScopes() {
        return [
            ['list', ['name', 'sku', 'producer_id', 'qty_available', 'is_active', 'is_shipping_enabled', 'is_in_stock', 'is_on_sale',]],
            [['create', 'update'], ['name', 'sku', 'permalink', 'producer_id', 'adminCollections', 'adminSets', 'qty_available', 'is_active', 'is_in_stock', 'is_on_sale',
                'is_shipping_enabled',
                'shippingConfig',
                'shippingConfig.is_tilt_allowed',
                'shippingConfig.weight',
                'shippingConfig.length',
                'shippingConfig.width',
                'shippingConfig.height', ]],
            ['delete', false],
        ];
    }

The shippingConfig.height field becomes always invisible.

@nadar nadar self-assigned this Jul 18, 2018
@nadar nadar added the bug label Jul 18, 2018
@nadar nadar removed their assignment Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants