Is it possible to map multiple inputs using MapInputName Attribute #187
Unanswered
Thavarajan
asked this question in
Q&A
Replies: 2 comments 6 replies
-
Hi @Thavarajan something like : class ContractData extends Data
{
public function __construct(
public string $name,
public string $recordCompany,
) {
}
public static function fromArray(array $contract)
{
return new self (
name: $contract['name],
recordCompany: $conrtact['company'] ? $conrtact['company'] : $conrtact['record_company'],
// or just $conrtact['record_company'] ?? $conrtact['company']
}
}
} this is a simple example but the point is that you can solve it in a simple way |
Beta Was this translation helpful? Give feedback.
1 reply
-
I don't think this is something we can implement easily, since we also need these names for validation. Which would we use then |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
for the above dataclass, i want to do the following
the first one is fine, I want to transform the second one also, how can i convert the second one, with the same data class
if i want to map the 'record_company', 'company' to that recordCompany field, is it possible?
Beta Was this translation helpful? Give feedback.
All reactions