public function serializeForLocale($locale, Dynamic $dynamic = null)
    {
        $fields = [];

        foreach ($this->fields as $field) {
            $fieldTranslation = $field->getTranslation($locale, false, true);
            $value = null;

            if ($dynamic) {
                $value = $dynamic->{$field->getKey()};
            }

            $fields[$field->getOrder()] = [
                'key' => $field->getKey(),
                'type' => $field->getType(),
                'title' => $fieldTranslation->getTitle(),
                'options' => $fieldTranslation->getOptions(),
                'defaultValue' => $fieldTranslation->getDefaultValue(),
                'placeholder' => $fieldTranslation->getPlaceholder(),
                'shortTitle' => $fieldTranslation->getShortTitle(),
                'value' => $value,
            ];

            ksort($fields);
        }

        $translation = $this->getTranslation($locale, false, true);

        return [
            'id' => $dynamic ? $dynamic->getId() : null,
            'formId' => $this->getId(),
            'title' => $translation->getTitle(),
            'subject' => $translation->getSubject(),
            'mailText' => $translation->getMailText(),
            'submitLabel' => $translation->getSubmitLabel(),
            'successText' => $translation->getSuccessText(),
            'fromEmail' => $translation->getFromEmail(),
            'fromName' => $translation->getFromName(),
            'toEmail' => $translation->getToEmail(),
            'toName' => $translation->getToName(),
            'fields' => $fields,
            'created' => $dynamic ? $dynamic->getCreated() : null,
        ];
    }
public function serializeForLocale($locale, Dynamic $dynamic = null)
    {
        $fields = [];

        foreach ($this->fields as $field) {
            $fieldTranslation = $field->getTranslation($locale, false, true);
            $value = null;

            if ($dynamic) {
                $value = $dynamic->{$field->getKey()};
            }

            $fields[$field->getOrder()] = [
                'key' => $field->getKey(),
                'type' => $field->getType(),
                'title' => $fieldTranslation->getTitle(),
                'options' => $fieldTranslation->getOptions(),
                'defaultValue' => $fieldTranslation->getDefaultValue(),
                'placeholder' => $fieldTranslation->getPlaceholder(),
                'shortTitle' => $fieldTranslation->getShortTitle(),
                'value' => $value,
            ];

            ksort($fields);
        }

        $translation = $this->getTranslation($locale, false, true);

        return [
            'id' => $dynamic ? $dynamic->getId() : null,
            'formId' => $this->getId(),
            'title' => $translation->getTitle(),
            'subject' => $translation->getSubject(),
            'mailText' => $translation->getMailText(),
            'submitLabel' => $translation->getSubmitLabel(),
            'successText' => $translation->getSuccessText(),
            'fromEmail' => $translation->getFromEmail(),
            'fromName' => $translation->getFromName(),
            'toEmail' => $translation->getToEmail(),
            'toName' => $translation->getToName(),
            'fields' => $fields,
            'created' => $dynamic ? $dynamic->getCreated() : null,
        ];
    }
public function serializeForLocale ( $ locale , Dynamic $ dynamic = null ) { $ fields = [ ] ; foreach ( $ this -> fields as $ field ) { $ fieldTranslation = $ field -> getTranslation ( $ locale , false , true ) ; $ value = null ; if ( $ dynamic ) { $ value = $ dynamic -> { $ field -> getKey ( ) } ; } $ fields [ $ field -> getOrder ( ) ] = [ 'key' => $ field -> getKey ( ) , 'type' => $ field -> getType ( ) , 'title' => $ fieldTranslation -> getTitle ( ) , 'options' => $ fieldTranslation -> getOptions ( ) , 'defaultValue' => $ fieldTranslation -> getDefaultValue ( ) , 'placeholder' => $ fieldTranslation -> getPlaceholder ( ) , 'shortTitle' => $ fieldTranslation -> getShortTitle ( ) , 'value' => $ value , ] ; ksort ( $ fields ) ; } $ translation = $ this -> getTranslation ( $ locale , false , true ) ; return [ 'id' => $ dynamic ? $ dynamic -> getId ( ) : null , 'formId' => $ this -> getId ( ) , 'title' => $ translation -> getTitle ( ) , 'subject' => $ translation -> getSubject ( ) , 'mailText' => $ translation -> getMailText ( ) , 'submitLabel' => $ translation -> getSubmitLabel ( ) , 'successText' => $ translation -> getSuccessText ( ) , 'fromEmail' => $ translation -> getFromEmail ( ) , 'fromName' => $ translation -> getFromName ( ) , 'toEmail' => $ translation -> getToEmail ( ) , 'toName' => $ translation -> getToName ( ) , 'fields' => $ fields , 'created' => $ dynamic ? $ dynamic -> getCreated ( ) : null , ] ; }
Return a localized array of the object.

@param $locale
@param Dynamic $dynamic

@return array
Return a localized array of the object .